midah commited on
Commit
c868574
·
verified ·
1 Parent(s): c65914a

Consolidated explorer shell on the Space: sidebar nav (eval/sessions toggle), bundled demo session, footer cross-nav to essay/arXiv/github; relative same-origin fetch; +2 datasets in SUGGESTED

Browse files
app.py CHANGED
@@ -60,6 +60,7 @@ from pathlib import Path
60
  from statistics import median
61
 
62
  from fastapi import FastAPI
 
63
  from fastapi.responses import FileResponse, JSONResponse
64
  from fastapi.staticfiles import StaticFiles
65
  from pydantic import BaseModel
@@ -94,6 +95,8 @@ SUGGESTED = (
94
  "ElenaFu/SWE-agent-trajectories",
95
  "nebius/SWE-rebench-openhands-trajectories",
96
  "SWE-bench/SWE-smith-trajectories",
 
 
97
  )
98
 
99
  # Canonical atom palette (kept in sync with the static explorer).
@@ -255,6 +258,20 @@ def _action_mix(traces: list[CachedTrace]) -> dict[str, float]:
255
  # API.
256
  app = FastAPI(title="ProcGrep explorer", docs_url="/api")
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  class QueryRequest(BaseModel):
260
  dataset: str = SUGGESTED[0]
 
60
  from statistics import median
61
 
62
  from fastapi import FastAPI
63
+ from fastapi.middleware.cors import CORSMiddleware
64
  from fastapi.responses import FileResponse, JSONResponse
65
  from fastapi.staticfiles import StaticFiles
66
  from pydantic import BaseModel
 
95
  "ElenaFu/SWE-agent-trajectories",
96
  "nebius/SWE-rebench-openhands-trajectories",
97
  "SWE-bench/SWE-smith-trajectories",
98
+ "nvidia/Nemotron-SFT-Agentic-v2",
99
+ "AlienKevin/SWE-ZERO-12M-trajectories",
100
  )
101
 
102
  # Canonical atom palette (kept in sync with the static explorer).
 
258
  # API.
259
  app = FastAPI(title="ProcGrep explorer", docs_url="/api")
260
 
261
+ # Allow the published Pages explorer to call the live query/compare API, so the
262
+ # static site can run example queries over whole datasets (not just its embedded
263
+ # samples). Read-only JSON endpoints; no credentials.
264
+ app.add_middleware(
265
+ CORSMiddleware,
266
+ allow_origins=[
267
+ "https://hamidah.me",
268
+ "http://localhost:8000",
269
+ "http://127.0.0.1:8000",
270
+ ],
271
+ allow_methods=["GET", "POST"],
272
+ allow_headers=["*"],
273
+ )
274
+
275
 
276
  class QueryRequest(BaseModel):
277
  dataset: str = SUGGESTED[0]
static/demo_session.json ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "meta": {
3
+ "name": "sample session",
4
+ "client": "Claude Code",
5
+ "project": "local \u00b7 anonymized",
6
+ "id": "8ff53f3c",
7
+ "date": "",
8
+ "intent": "atoms only \u00b7 shareable export, no prompt text",
9
+ "illustrative": false,
10
+ "real": true,
11
+ "models": [],
12
+ "counts": {
13
+ "turns": 12,
14
+ "atoms": 337,
15
+ "atom_counts": {
16
+ "edit": 123,
17
+ "prompt_ai": 13,
18
+ "other": 36,
19
+ "search_repo": 24,
20
+ "read_file": 100,
21
+ "version_control": 18,
22
+ "run_test": 11,
23
+ "lint": 2,
24
+ "run_code": 10
25
+ }
26
+ }
27
+ },
28
+ "turns": [
29
+ {
30
+ "t": "",
31
+ "model": "",
32
+ "prompt": "",
33
+ "plan": "",
34
+ "seq": [
35
+ "edit"
36
+ ]
37
+ },
38
+ {
39
+ "t": "",
40
+ "model": "",
41
+ "prompt": "",
42
+ "plan": "",
43
+ "seq": [
44
+ "edit"
45
+ ]
46
+ },
47
+ {
48
+ "t": "",
49
+ "model": "",
50
+ "prompt": "",
51
+ "plan": "",
52
+ "seq": [
53
+ "other",
54
+ "search_repo",
55
+ "read_file",
56
+ "search_repo",
57
+ "search_repo",
58
+ "version_control",
59
+ "other",
60
+ "other",
61
+ "search_repo",
62
+ "search_repo",
63
+ "other",
64
+ "other",
65
+ "other",
66
+ "other",
67
+ "other",
68
+ "other",
69
+ "other",
70
+ "run_test",
71
+ "other",
72
+ "other",
73
+ "search_repo",
74
+ "search_repo",
75
+ "search_repo",
76
+ "other",
77
+ "other",
78
+ "search_repo",
79
+ "search_repo",
80
+ "other",
81
+ "other",
82
+ "search_repo",
83
+ "other",
84
+ "other",
85
+ "run_test",
86
+ "read_file",
87
+ "search_repo",
88
+ "search_repo",
89
+ "lint",
90
+ "other",
91
+ "other",
92
+ "other",
93
+ "run_code",
94
+ "other",
95
+ "read_file",
96
+ "read_file",
97
+ "version_control"
98
+ ]
99
+ },
100
+ {
101
+ "t": "",
102
+ "model": "",
103
+ "prompt": "",
104
+ "plan": "",
105
+ "seq": [
106
+ "edit"
107
+ ]
108
+ },
109
+ {
110
+ "t": "",
111
+ "model": "",
112
+ "prompt": "",
113
+ "plan": "",
114
+ "seq": [
115
+ "version_control",
116
+ "version_control",
117
+ "version_control",
118
+ "version_control",
119
+ "other",
120
+ "other",
121
+ "other",
122
+ "read_file",
123
+ "read_file",
124
+ "read_file",
125
+ "edit",
126
+ "edit",
127
+ "edit",
128
+ "edit",
129
+ "read_file",
130
+ "edit",
131
+ "edit",
132
+ "read_file",
133
+ "edit",
134
+ "edit",
135
+ "read_file",
136
+ "read_file",
137
+ "read_file",
138
+ "edit",
139
+ "edit",
140
+ "edit",
141
+ "edit",
142
+ "read_file",
143
+ "read_file",
144
+ "read_file",
145
+ "read_file",
146
+ "edit",
147
+ "edit",
148
+ "edit",
149
+ "edit",
150
+ "edit",
151
+ "search_repo",
152
+ "version_control",
153
+ "lint",
154
+ "other",
155
+ "run_code",
156
+ "other",
157
+ "run_code",
158
+ "run_code",
159
+ "run_code",
160
+ "run_test",
161
+ "other",
162
+ "other",
163
+ "version_control",
164
+ "edit"
165
+ ]
166
+ },
167
+ {
168
+ "t": "",
169
+ "model": "",
170
+ "prompt": "",
171
+ "plan": "",
172
+ "seq": [
173
+ "other",
174
+ "read_file",
175
+ "run_test",
176
+ "run_test",
177
+ "run_test",
178
+ "run_test",
179
+ "run_code",
180
+ "search_repo",
181
+ "read_file",
182
+ "search_repo",
183
+ "edit"
184
+ ]
185
+ },
186
+ {
187
+ "t": "",
188
+ "model": "",
189
+ "prompt": "",
190
+ "plan": "",
191
+ "seq": [
192
+ "version_control",
193
+ "version_control",
194
+ "version_control",
195
+ "version_control",
196
+ "version_control",
197
+ "edit"
198
+ ]
199
+ },
200
+ {
201
+ "t": "",
202
+ "model": "",
203
+ "prompt": "",
204
+ "plan": "",
205
+ "seq": [
206
+ "other",
207
+ "read_file",
208
+ "read_file",
209
+ "read_file",
210
+ "read_file",
211
+ "read_file",
212
+ "read_file",
213
+ "read_file",
214
+ "read_file",
215
+ "read_file",
216
+ "read_file",
217
+ "read_file",
218
+ "read_file",
219
+ "read_file",
220
+ "read_file",
221
+ "read_file",
222
+ "read_file",
223
+ "edit",
224
+ "edit",
225
+ "edit",
226
+ "edit",
227
+ "edit",
228
+ "edit",
229
+ "edit",
230
+ "edit",
231
+ "edit",
232
+ "edit",
233
+ "edit",
234
+ "edit",
235
+ "edit",
236
+ "edit",
237
+ "edit",
238
+ "edit",
239
+ "edit",
240
+ "edit",
241
+ "edit",
242
+ "edit",
243
+ "edit",
244
+ "edit",
245
+ "other",
246
+ "other",
247
+ "run_test",
248
+ "read_file",
249
+ "run_code",
250
+ "search_repo",
251
+ "version_control"
252
+ ]
253
+ },
254
+ {
255
+ "t": "",
256
+ "model": "",
257
+ "prompt": "",
258
+ "plan": "",
259
+ "seq": [
260
+ "edit",
261
+ "run_code",
262
+ "read_file",
263
+ "edit",
264
+ "edit",
265
+ "read_file",
266
+ "read_file",
267
+ "edit",
268
+ "read_file",
269
+ "edit",
270
+ "edit",
271
+ "edit",
272
+ "read_file",
273
+ "edit",
274
+ "edit",
275
+ "read_file",
276
+ "read_file",
277
+ "edit",
278
+ "read_file",
279
+ "read_file",
280
+ "edit",
281
+ "edit",
282
+ "edit",
283
+ "read_file",
284
+ "edit",
285
+ "read_file",
286
+ "edit",
287
+ "edit",
288
+ "read_file",
289
+ "edit",
290
+ "edit",
291
+ "read_file",
292
+ "edit",
293
+ "read_file",
294
+ "edit",
295
+ "read_file",
296
+ "read_file",
297
+ "edit",
298
+ "read_file",
299
+ "edit",
300
+ "edit",
301
+ "read_file",
302
+ "edit",
303
+ "read_file",
304
+ "edit",
305
+ "edit",
306
+ "read_file",
307
+ "edit",
308
+ "read_file",
309
+ "edit",
310
+ "other",
311
+ "search_repo",
312
+ "read_file",
313
+ "read_file",
314
+ "edit",
315
+ "edit",
316
+ "read_file",
317
+ "read_file",
318
+ "edit",
319
+ "read_file",
320
+ "edit",
321
+ "read_file",
322
+ "read_file",
323
+ "edit",
324
+ "read_file",
325
+ "edit",
326
+ "read_file",
327
+ "read_file",
328
+ "edit",
329
+ "read_file",
330
+ "edit",
331
+ "read_file",
332
+ "read_file",
333
+ "edit",
334
+ "edit",
335
+ "read_file",
336
+ "edit",
337
+ "edit",
338
+ "read_file",
339
+ "edit",
340
+ "edit",
341
+ "read_file",
342
+ "edit",
343
+ "read_file",
344
+ "search_repo",
345
+ "search_repo",
346
+ "read_file",
347
+ "edit",
348
+ "read_file",
349
+ "edit",
350
+ "read_file",
351
+ "edit",
352
+ "edit",
353
+ "read_file",
354
+ "edit",
355
+ "edit",
356
+ "read_file",
357
+ "read_file",
358
+ "edit",
359
+ "edit",
360
+ "search_repo",
361
+ "read_file",
362
+ "edit",
363
+ "read_file",
364
+ "read_file",
365
+ "edit",
366
+ "edit",
367
+ "read_file",
368
+ "edit",
369
+ "edit",
370
+ "read_file",
371
+ "read_file",
372
+ "edit",
373
+ "read_file",
374
+ "edit",
375
+ "edit",
376
+ "read_file",
377
+ "edit",
378
+ "read_file",
379
+ "read_file",
380
+ "edit",
381
+ "edit",
382
+ "read_file",
383
+ "read_file",
384
+ "edit",
385
+ "edit",
386
+ "read_file",
387
+ "edit",
388
+ "read_file",
389
+ "read_file",
390
+ "edit",
391
+ "edit",
392
+ "read_file",
393
+ "read_file",
394
+ "edit",
395
+ "read_file",
396
+ "read_file",
397
+ "edit",
398
+ "edit",
399
+ "run_code",
400
+ "search_repo",
401
+ "search_repo",
402
+ "version_control"
403
+ ]
404
+ },
405
+ {
406
+ "t": "",
407
+ "model": "",
408
+ "prompt": "",
409
+ "plan": "",
410
+ "seq": [
411
+ "edit",
412
+ "version_control",
413
+ "run_test",
414
+ "other"
415
+ ]
416
+ },
417
+ {
418
+ "t": "",
419
+ "model": "",
420
+ "prompt": "",
421
+ "plan": "",
422
+ "seq": [
423
+ "edit",
424
+ "run_test",
425
+ "version_control",
426
+ "run_code",
427
+ "version_control",
428
+ "run_test"
429
+ ]
430
+ },
431
+ {
432
+ "t": "",
433
+ "model": "",
434
+ "prompt": "",
435
+ "plan": "",
436
+ "seq": [
437
+ "edit",
438
+ "other",
439
+ "edit",
440
+ "edit",
441
+ "read_file",
442
+ "edit",
443
+ "search_repo",
444
+ "read_file",
445
+ "edit",
446
+ "edit"
447
+ ]
448
+ }
449
+ ]
450
+ }
static/index.html CHANGED
@@ -2,14 +2,81 @@
2
  <html lang="en"><head>
3
  <meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
4
  <title>procgrep · query agent traces, live</title>
5
- <link rel="stylesheet" href="static/style.css">
6
- </head><body><div class="wrap">
7
- <nav class="tabs">
8
- <span class="tab act" id="tab-query" onclick="showView('query')">query</span>
9
- <span class="tab" id="tab-compare" onclick="showView('compare')">compare</span>
10
- <a class="tab plain" href="https://github.com/hamidahoderinwale/procgrep" target="_blank" rel="noopener">github ↗</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  </nav>
12
 
 
 
 
 
 
13
  <section id="view-query">
14
  <h1>Grep agent traces, live.</h1>
15
  <p class="sub">Ask a structural question about how an agent worked and get an exact answer over the whole
@@ -44,6 +111,71 @@ action-mix distance, and the length and reasoning gaps. No model call.</p>
44
  <div id="cmp-res"></div>
45
  </section>
46
 
 
 
 
 
 
 
 
 
 
 
47
  </div>
48
- <script src="static/app.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  </body></html>
 
2
  <html lang="en"><head>
3
  <meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
4
  <title>procgrep · query agent traces, live</title>
5
+ <link rel="stylesheet" href="/static/theme.css">
6
+ <link rel="stylesheet" href="/static/style.css">
7
+ <style>
8
+ /* Global sidebar nav, mirrored from the published explorer so the Space and the
9
+ Pages site share one chrome: a surface toggle (eval/sessions), the per-surface
10
+ nav, a session list the embedded panel fills, and a footer out to the essay,
11
+ arXiv, and GitHub. The eval content keeps the live query + compare views and
12
+ talks to this same backend over same-origin relative paths. */
13
+ body{padding-left:212px}
14
+ .railnav{position:fixed;left:0;top:0;bottom:0;width:212px;padding:22px 14px;overflow:auto;background:#EFEAE2;display:flex;flex-direction:column}
15
+ .railnav .mark{margin:0 6px 14px;font-weight:600;display:inline-flex;align-items:center;gap:9px;color:var(--ink);text-decoration:none}
16
+ .railnav .mark::before{content:"";width:8px;height:8px;background:var(--copper);border-radius:1px}
17
+ .railnav .surf{display:flex;gap:3px;margin:0 0 16px;background:#E2DBD0;border-radius:7px;padding:3px}
18
+ .railnav .surf button{flex:1;text-align:center;font:11px var(--mono);border:0;background:transparent;color:var(--olive);padding:6px 3px;border-radius:5px;cursor:pointer}
19
+ .railnav .surf button.on{background:var(--ink);color:#fff}
20
+ .railnav .railfoot{margin-top:auto;border-top:1px solid var(--rule);padding-top:10px;display:flex;flex-direction:column;gap:1px}
21
+ .railnav .railfoot a{display:flex;align-items:center;gap:8px;font-size:12px;padding:5px 6px;border-radius:6px;text-decoration:none;color:var(--olive)}
22
+ .railnav .railfoot a:hover{color:var(--ink);background:rgba(20,17,14,.06)}
23
+ .railnav .railfoot .ico{flex:0 0 15px;width:15px;height:15px;display:inline-flex;align-items:center;justify-content:center}
24
+ .railnav .railfoot .ico svg{width:14px;height:14px;fill:currentColor}
25
+ .railnav .railfoot .ext{margin-left:auto;font-size:10px;color:var(--olive)}
26
+ .railnav .railfoot .meta{margin-top:9px;padding:0 6px;font-size:10.5px;line-height:1.55;color:var(--olive)}
27
+ .railnav #sesslist .sessitem{display:block;line-height:1.32;padding:7px 10px;text-align:left}
28
+ .railnav #sesslist .sessitem .nnm{display:block;font-size:13px}
29
+ .railnav #sesslist .sessitem .smeta{display:block;font-size:10px;color:var(--olive)}
30
+ .railnav #sesslist .sessitem.act .smeta{color:#cfc9bf}
31
+ .railnav h2{font-size:10px;letter-spacing:.07em;text-transform:uppercase;color:var(--olive);margin:0 0 12px;font-weight:600}
32
+ .railnav .ritem{display:block;width:100%;text-align:left;font-family:var(--mono);font-size:13px;border:0;background:transparent;color:var(--ink);padding:8px 10px;border-radius:6px;cursor:pointer;margin:0 0 2px}
33
+ .railnav .ritem:hover{background:#ECE7DF}
34
+ .railnav .ritem.act{background:var(--ink);color:#fff}
35
+ .cgroup{display:contents}
36
+ body.corpus-eval .cgroup[data-c="sess"]{display:none}
37
+ body.corpus-sess .cgroup[data-c="eval"]{display:none}
38
+ /* The wrap drops the explorer's own top tab row; the rail is the nav now. */
39
+ .tabs{display:none}
40
+ #sessframe{width:100%;height:80vh;border:0;border-radius:6px;background:#fff}
41
+ .sesscallout{margin:14px 0 0;padding:10px 14px;border:1px solid var(--rule);background:#fff;color:var(--olive);font-size:12px;line-height:1.55}
42
+ .sesscallout code{background:#efeae2;padding:1px 6px;border-radius:3px;color:var(--ink)}
43
+ @media(max-width:720px){
44
+ body{padding-left:0}
45
+ .railnav{position:static;width:auto;height:auto;padding:12px 16px;background:#EFEAE2;
46
+ display:flex;flex-wrap:wrap;align-items:center;gap:4px}
47
+ .railnav h2{margin:0 4px 0 0;font-size:9px}
48
+ .railnav .ritem{display:inline-block;width:auto;padding:6px 9px;margin:0}
49
+ .railnav .railfoot{flex-direction:row;flex-wrap:wrap;margin:0 0 0 8px;border:0;padding:0}
50
+ .railnav .railfoot .meta{display:none}
51
+ }
52
+ </style>
53
+ </head><body class="corpus-eval">
54
+ <nav class="railnav">
55
+ <a class="mark" href="/">procgrep</a>
56
+ <div class="surf">
57
+ <button id="c-eval" class="on" onclick="pickCorpus('eval')">eval</button>
58
+ <button id="c-sess" onclick="pickCorpus('sess')">sessions</button>
59
+ </div>
60
+ <div class="cgroup" data-c="eval">
61
+ <button class="ritem act" id="nav-query" onclick="showView('query')">query</button>
62
+ <button class="ritem" id="nav-compare" onclick="showView('compare')">compare</button>
63
+ </div>
64
+ <div class="cgroup" data-c="sess">
65
+ <div id="sesslist"><span class="dim" style="display:block;padding:8px 10px;font-size:11px">loading sessions…</span></div>
66
+ </div>
67
+ <div class="railfoot">
68
+ <a href="https://hamidah.me/procgrep/"><span class="ico"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 1.5h10A1.5 1.5 0 0 1 14.5 3v10a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 13V3A1.5 1.5 0 0 1 3 1.5zM4.5 5h7v1.2h-7V5zm0 2.6h7v1.2h-7V7.6zm0 2.6h4.5v1.2H4.5v-1.2z"/></svg></span>essay<span class="ext">↗</span></a>
69
+ <a href="https://arxiv.org/abs/2606.16988"><span class="ico"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9 1H4a1.6 1.6 0 0 0-1.6 1.6v10.8A1.6 1.6 0 0 0 4 15h8a1.6 1.6 0 0 0 1.6-1.6V5.5L9 1zm0 1.7L12.3 6H9V2.7zM5 8.4h6V9.6H5V8.4zm0 2.4h6V12H5v-1.2z"/></svg></span>arXiv<span class="ext">↗</span></a>
70
+ <a href="https://github.com/hamidahoderinwale/procgrep"><span class="ico"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.02-1.49-2.22.48-2.69-1.07-2.69-1.07-.36-.92-.89-1.17-.89-1.17-.73-.5.05-.49.05-.49.81.06 1.23.83 1.23.83.72 1.23 1.88.88 2.34.67.07-.52.28-.88.51-1.08-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.83-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.52.56.83 1.28.83 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8 8 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg></span>github<span class="ext">↗</span></a>
71
+ <div class="meta">June 2026</div>
72
+ </div>
73
  </nav>
74
 
75
+ <div class="wrap">
76
+ <!-- app.js's showView toggles these tab elements; the rail is the visible nav so
77
+ they are kept hidden purely to satisfy that DOM contract. -->
78
+ <nav class="tabs" hidden><span class="tab" id="tab-query"></span><span class="tab" id="tab-compare"></span></nav>
79
+
80
  <section id="view-query">
81
  <h1>Grep agent traces, live.</h1>
82
  <p class="sub">Ask a structural question about how an agent worked and get an exact answer over the whole
 
111
  <div id="cmp-res"></div>
112
  </section>
113
 
114
+ <section id="view-sessions" class="hidden">
115
+ <h1>One session, as a procedural fingerprint.</h1>
116
+ <p class="sub">A real Claude Code session reduced to its action structure: each human prompt opens a turn,
117
+ and the agent's tool calls become the turn's atoms. Pick it in the sidebar, replay it, or run an atom
118
+ pattern over it — the same grammar as the eval query.</p>
119
+ <iframe id="sessframe" title="live procedural fingerprint"></iframe>
120
+ <p class="sesscallout">These are sample traces. Run procgrep locally to explore your own sessions:
121
+ <code>python examples/procgrep_view.py</code></p>
122
+ </section>
123
+
124
  </div>
125
+
126
+ <script src="/static/app.js"></script>
127
+ <script>
128
+ // Surface toggle + session-list plumbing for the global rail. The eval views
129
+ // (query/compare) live in app.js and already fetch this backend over relative
130
+ // paths; this script only adds the eval/sessions switch and wires the sessions
131
+ // rail to the embedded fingerprint panel. One rail, not two.
132
+ const _origShowView = window.showView;
133
+ window.showView = function(name, axis){
134
+ document.getElementById("view-query").classList.toggle("hidden", name !== "query");
135
+ document.getElementById("view-compare").classList.toggle("hidden", name !== "compare");
136
+ document.getElementById("view-sessions").classList.toggle("hidden", name !== "sessions");
137
+ document.getElementById("nav-query").classList.toggle("act", name === "query");
138
+ document.getElementById("nav-compare").classList.toggle("act", name === "compare");
139
+ if(name === "sessions"){ ensureSessFrame(); return; }
140
+ // Defer to app.js for the eval views (it owns the comparator init/axis logic).
141
+ if(_origShowView) _origShowView(name, axis);
142
+ };
143
+
144
+ let _sessLoaded = false;
145
+ function ensureSessFrame(){
146
+ const f = document.getElementById("sessframe");
147
+ if(!_sessLoaded){ _sessLoaded = true; f.src = "/static/live_fingerprint.html?embed=1&demo=1"; }
148
+ }
149
+
150
+ function pickCorpus(c){
151
+ document.body.classList.remove("corpus-eval","corpus-sess");
152
+ document.body.classList.add("corpus-" + c);
153
+ document.getElementById("c-eval").classList.toggle("on", c === "eval");
154
+ document.getElementById("c-sess").classList.toggle("on", c === "sess");
155
+ showView(c === "sess" ? "sessions" : "query");
156
+ }
157
+
158
+ // The embedded panel posts its session list up; render it in the global rail and
159
+ // post the selection back so it loads in the iframe. Mirrors the Pages explorer.
160
+ function renderSessList(msg){
161
+ const el = document.getElementById("sesslist"); if(!el) return;
162
+ const active = msg.hasOverview ? "ov" : (msg.list[0] ? msg.list[0].i : null);
163
+ let html = msg.hasOverview
164
+ ? `<button class="ritem sessitem${active==="ov"?" act":""}" onclick="selectSession(null,this)"><span class="nnm">overview</span><span class="smeta">run length across sessions</span></button>`
165
+ : "";
166
+ html += msg.list.map(s =>
167
+ `<button class="ritem sessitem${active===s.i?" act":""}" onclick="selectSession(${s.i},this)"><span class="nnm">${s.name}</span><span class="smeta">${s.client}${s.date?` · ${s.date}`:""}${s.dur?` · ${s.dur}`:""}</span></button>`
168
+ ).join("");
169
+ el.innerHTML = html || '<span class="dim" style="display:block;padding:8px 10px;font-size:11px">no sessions</span>';
170
+ }
171
+ function selectSession(i, btn){
172
+ const f = document.getElementById("sessframe");
173
+ if(f && f.contentWindow) f.contentWindow.postMessage({type:"procgrep-select", index:i}, "*");
174
+ document.querySelectorAll("#sesslist .sessitem").forEach(b => b.classList.remove("act"));
175
+ if(btn) btn.classList.add("act");
176
+ }
177
+ window.addEventListener("message", e => {
178
+ if(e.data && e.data.type === "procgrep-sessions") renderSessList(e.data);
179
+ });
180
+ </script>
181
  </body></html>
static/live_fingerprint.html ADDED
@@ -0,0 +1,697 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>procgrep · live procedural fingerprint</title>
7
+ <link rel="stylesheet" href="theme.css">
8
+ <style>
9
+ /* Base colors come from theme.css; alias the panel's semantic names to them
10
+ and keep the atom, outcome, and rule shades that are specific to the panel. */
11
+ :root{
12
+ --bg:var(--paper); --mut:var(--olive); --line:#E2DCD3;
13
+ --edit:var(--copper); --read:var(--blue); --fail:var(--copper);
14
+ --prompt:#9A6CB4; --test:#4A7C59; --other:#A99B86;
15
+ --search:#2E8B8B; --package:#C08A2E; --lint:#9A5B4A; --vcs:#4E6A8A;
16
+ --run:#6E7B8B; --pass:#4A7C59;
17
+ }
18
+ *{box-sizing:border-box}
19
+ body{background:var(--bg);color:var(--ink);font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;margin:0;padding:40px 20px 40px 250px}
20
+ .panel{max-width:760px;margin:0 auto}
21
+ .nav{position:fixed;left:0;top:0;bottom:0;width:212px;padding:40px 16px;overflow:auto;background:#EFEAE2}
22
+ .nav h2{font-size:10px;letter-spacing:.07em;text-transform:uppercase;color:var(--mut);margin:0 0 12px;font-weight:600}
23
+ .nav button{display:block;width:100%;text-align:left;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;
24
+ border:0;background:transparent;color:var(--ink);padding:8px 10px;border-radius:6px;cursor:pointer;margin-bottom:2px}
25
+ .nav button:hover{background:#ECE7DF}
26
+ .nav button.active{background:var(--ink);color:#fff}
27
+ .nav .nnm{display:block;font-weight:600}
28
+ .nav .nmeta{display:block;font-size:10px;color:var(--mut);margin-top:2px}
29
+ .nav button.active .nmeta{color:#cfcabf}
30
+ .topbar{display:flex;align-items:center;justify-content:space-between;margin:0 0 22px}
31
+ .topbar .mark{font-size:13px;font-weight:600;letter-spacing:.04em;display:inline-flex;align-items:center;gap:9px;color:var(--ink);text-decoration:none}
32
+ .topbar .mark::before{content:"";width:8px;height:8px;background:var(--edit);border-radius:1px}
33
+ .topnav a{color:var(--mut);text-decoration:none;margin-left:18px;font-size:12px}
34
+ .topnav a:hover{color:var(--ink)}
35
+ .topnav a.active{color:var(--ink);font-weight:600;border-bottom:2px solid var(--edit);padding-bottom:3px}
36
+ .topnav a.dim{color:var(--mut)}
37
+ .replay{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;display:inline-flex;align-items:center;gap:7px;
38
+ background:var(--ink);color:#fff;border:0;padding:6px 14px;border-radius:999px;cursor:pointer}
39
+ .replay:hover{opacity:.88}
40
+ .replay .tri{font-size:10px}
41
+
42
+ .idcard{background:#fff;border-radius:6px;padding:14px 16px}
43
+ .idrow{display:flex;gap:12px;margin:3px 0;font-size:12px}
44
+ .idrow .k{width:76px;flex:0 0 auto;color:var(--mut);font-size:11px}
45
+ .idrow .v{color:var(--ink);font-weight:600}
46
+ .idrow .v.hash{font-weight:400;color:var(--mut)}
47
+ .intent{color:var(--mut);font-size:12px;margin:11px 0 13px}
48
+ .intent .tag{font-size:10px;background:#ECE7DF;color:var(--mut);padding:1px 6px;border-radius:3px;margin-left:6px}
49
+
50
+ .stats{font-size:12px;color:var(--mut);line-height:1.75;margin:0}
51
+ .topgrid{display:grid;grid-template-columns:1fr 300px;gap:30px;align-items:start;margin-bottom:26px}
52
+ .stats b{color:var(--ink);font-weight:600}
53
+ .stats .idrow{align-items:center}
54
+ .stats .k{width:112px}
55
+ .stats .models{display:flex;align-items:center;gap:9px;margin-top:0}
56
+ .mbar{display:inline-flex;width:150px;height:8px;border-radius:2px;overflow:hidden}
57
+ .mbar .seg{height:100%}
58
+ .ml{white-space:nowrap}
59
+ .sw{display:inline-block;width:7px;height:7px;border-radius:1px;margin-right:4px}
60
+
61
+ .cap{font-size:11px;letter-spacing:.06em;color:var(--mut);text-transform:uppercase;margin:0 0 10px}
62
+ .tlhead{display:flex;align-items:center;justify-content:space-between;margin:0 0 6px}
63
+ .cap .hint{text-transform:none;letter-spacing:0;font-size:10px;opacity:.85}
64
+ .privbar{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--mut);margin:0 0 22px}
65
+ .privbar button{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;border:0;background:#ECE7DF;color:var(--mut);padding:3px 11px;border-radius:999px;cursor:pointer}
66
+ .privbar button.on{background:var(--ink);color:#fff}
67
+ .turn .pr-count{margin:2px 0;color:var(--mut);font-size:11px}
68
+ .turn .pr-text{margin:2px 0}
69
+ body.pmode-counts .pr-text, body.pmode-counts .turn .plan{display:none}
70
+ body.pmode-shown .pr-count{display:none}
71
+
72
+ .atomsec{max-width:540px;margin-bottom:24px}
73
+ .procline{font-size:12px;color:var(--mut);margin:16px 0 0}
74
+ .procline .chain{color:var(--ink);font-weight:600}
75
+
76
+ .atom{display:flex;align-items:center;gap:9px;margin:6px 0;cursor:pointer;user-select:none}
77
+ .atom .dot{width:7px;height:7px;border-radius:50%;background:transparent;flex:0 0 auto}
78
+ .atom.sel .dot{background:var(--ink)}
79
+ .atom .nm{width:128px;flex:0 0 auto;color:var(--mut)}
80
+ .atom.sel .nm{color:var(--ink);font-weight:600}
81
+ .track{flex:1;height:11px;background:#ECE7DF;border-radius:2px;overflow:hidden}
82
+ .fill{display:block;height:100%;width:0;border-radius:2px;transition:width .28s ease}
83
+ .atom .pc{width:34px;text-align:right;font-weight:600}
84
+ .fnote{font-size:11px;color:var(--mut);margin-top:8px;min-height:1em}
85
+ .fnote a{color:var(--read);cursor:pointer}
86
+ .tip{display:inline-flex;align-items:center;gap:10px;background:#fff;border-radius:6px;box-shadow:0 1px 5px rgba(0,0,0,.06);padding:5px 10px;font-size:11px;color:var(--mut);margin:0 0 12px}
87
+ .tip .x{cursor:pointer;font-size:10px;opacity:.7}
88
+ .tip .x:hover{opacity:1}
89
+ .tip.hidden{display:none}
90
+
91
+ .parabox{background:#fff;border-radius:6px;padding:14px 16px;font-size:11px;color:var(--mut)}
92
+ .parabox .note{margin-bottom:11px;line-height:1.6}
93
+ .pex{display:flex;gap:12px;margin:4px 0;align-items:baseline}
94
+ .plab{width:46px;flex:0 0 auto;text-align:right;color:var(--mut)}
95
+ .praw{color:#A99B86;text-decoration:line-through}
96
+ .pnorm{color:var(--ink);font-weight:500}
97
+
98
+ .tlleg{font-size:10px;color:var(--mut);margin:0 0 12px;padding-left:15px;line-height:1.95}
99
+ .tlleg li{margin:0}
100
+ .bluedot{display:inline-block;width:8px;height:8px;border-radius:50%;border:2px solid var(--read);background:#fff;vertical-align:middle}
101
+ .badge{display:inline-block;font-size:10px;font-weight:600;padding:1px 7px;border-radius:3px;margin-left:8px;vertical-align:middle;white-space:nowrap}
102
+ .badge.pass{background:#E3EDE6;color:var(--pass)}
103
+ .badge.fail{background:#F6E3DC;color:var(--fail)}
104
+
105
+ .tl{max-height:560px;overflow:auto;background:#fff;border-radius:6px;padding:16px 18px}
106
+ .turn{position:relative;display:grid;grid-template-columns:1fr 40%;gap:18px;padding:0 0 16px 24px;transition:opacity .2s}
107
+ .turn::before{content:"";position:absolute;left:5px;top:5px;bottom:-3px;width:2px;background:var(--line)}
108
+ .turn:last-child::before{display:none}
109
+ .turn .node{position:absolute;left:0;top:3px;width:11px;height:11px;border-radius:50%;background:var(--other);border:2px solid #fff}
110
+ .turn.inwin::before{background:var(--read)}
111
+ .turn.inwin .node{border-color:var(--read)}
112
+ .turn.now .node{box-shadow:0 0 0 3px rgba(203,77,32,.30)}
113
+ .turn.future{opacity:.24}
114
+ .turn.dim{opacity:.18}
115
+ .turnmain{min-width:0}
116
+ .turn .when{color:var(--mut);font-size:11px}
117
+ .turn .when b{color:var(--ink);font-weight:600}
118
+ .turn.now .when b{color:var(--edit)}
119
+ .turn .mtag{font-size:10px;margin-left:6px}
120
+ .turn .pr{margin:2px 0}
121
+ .turn .acts{margin-top:4px;padding-left:13px}
122
+ .turn .act{font-size:12px;color:var(--mut);line-height:1.7}
123
+ .turn .act .br{color:#C9C2B6;margin-right:5px}
124
+ .turn .plan{color:var(--mut);font-style:italic;font-size:11px;line-height:1.5;align-self:start}
125
+ .winmark{position:relative;padding:0 0 14px 24px;color:var(--mut);font-size:10px}
126
+ .winmark::before{content:"";position:absolute;left:5px;top:0;bottom:0;width:2px;background:var(--line)}
127
+ code{font-size:11px}
128
+ .hidden{display:none}
129
+ .nav button.hidden{display:none} /* beat .nav button{display:block} specificity */
130
+ #autonomy .chart{background:#fff;border-radius:6px;padding:18px 20px 10px}
131
+ #autonomy .cap2{color:var(--mut);font-size:12px;margin:10px 2px 0}
132
+ #autonomy .sqbar{display:flex;align-items:center;gap:7px;border:2px solid var(--ink);background:#fff;padding:8px 12px;margin:0 0 6px;color:var(--mut)}
133
+ #autonomy .sqbar input{flex:1;border:0;background:transparent;font:14px ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--ink)}
134
+ #autonomy .sqbar input:focus{outline:none}
135
+ #autonomy .sqnote{color:var(--mut);font-size:11px;margin:0 2px 16px}
136
+ #autonomy .astats{display:flex;flex-wrap:wrap;gap:26px;margin:18px 2px 0}
137
+ #autonomy .astats .sv{font-size:20px;font-weight:600;color:var(--ink)}
138
+ #autonomy .astats .sl{font-size:11px;color:var(--mut);text-transform:uppercase;letter-spacing:.05em;margin-top:2px}
139
+ .nav #overviewNav button .nmeta{color:var(--mut)}
140
+ .nav #overviewNav .ovrow{display:flex;align-items:center;gap:8px}
141
+ .nav #overviewNav .ovico rect{fill:var(--edit)}
142
+ .nav #overviewNav button.active .ovico rect{fill:#fff}
143
+ @media(max-width:720px){
144
+ body{padding:22px 16px 40px}
145
+ .panel{max-width:none}
146
+ .nav{position:static;width:auto;height:auto;padding:12px 16px;margin-bottom:18px;background:#EFEAE2;
147
+ display:flex;flex-wrap:wrap;align-items:center;gap:4px}
148
+ .nav h2{margin:0 4px 0 0}
149
+ .nav button{display:inline-block;width:auto;padding:6px 9px;margin:0}
150
+ .nav .nmeta{display:none}
151
+ .topbar{flex-wrap:wrap;gap:8px;margin-bottom:16px}
152
+ .topgrid{grid-template-columns:1fr;gap:16px;margin-bottom:18px}
153
+ .stats .k{width:104px}
154
+ .atomsec,.parabox{max-width:none}
155
+ .atom .nm{width:108px}
156
+ }
157
+ </style>
158
+ </head>
159
+ <body class="pmode-shown">
160
+ <nav class="nav">
161
+ <div id="overviewNav"></div>
162
+ <h2>sessions</h2>
163
+ <div id="switch"></div>
164
+ </nav>
165
+ <div class="panel">
166
+
167
+ <header class="topbar">
168
+ <a class="mark" href="index.html">procgrep</a>
169
+ <nav class="topnav">
170
+ <a href="index.html">essay</a>
171
+ <a href="explorer/index.html">explorer</a>
172
+ </nav>
173
+ </header>
174
+
175
+ <div id="detail">
176
+ <div class="topgrid">
177
+ <div class="idcard">
178
+ <div id="ident"></div>
179
+ <p class="intent" id="intent"></p>
180
+ <div class="stats" id="stats"></div>
181
+ </div>
182
+ <div class="parabox">
183
+ <div class="note">prompts are normalized locally before display: writing style and identifiers stripped, never stored or exported</div>
184
+ <div class="pex"><span class="plab">raw</span><span class="praw">"why does our FooBarAuth.validate() still 500 on null sub?"</span></div>
185
+ <div class="pex"><span class="plab">shown</span><span class="pnorm">"handle the null-subject case in token validation"</span></div>
186
+ </div>
187
+ </div>
188
+
189
+ <div class="privbar">prompts
190
+ <button id="privtog" class="on" onclick="togglePriv()">show text</button>
191
+ </div>
192
+
193
+ <div class="atomsec">
194
+ <p class="cap">Atoms <span class="hint" id="atomsHint"></span></p>
195
+ <div class="tip" id="tip"><span>tap an atom to filter the timeline below</span><span class="x" onclick="closeTip()">✕</span></div>
196
+ <div id="atoms"></div>
197
+ <div class="fnote" id="fnote"></div>
198
+ <p class="procline">top procedure · <span class="chain" id="procChain"></span> · <span class="pw" id="procW"></span><span id="procGloss"></span></p>
199
+ </div>
200
+
201
+ <div class="tlhead">
202
+ <p class="cap" style="margin:0">Timeline <span class="hint">· the session as a thread · each turn's plan on the right</span></p>
203
+ <button class="replay" id="replayBtn" onclick="toggleReplay()"><span class="tri">▶</span> <span id="rlab">Replay session</span></button>
204
+ </div>
205
+ <ul class="tlleg">
206
+ <li>each turn is your prompt, then the agent's tool sequence; the dot is colored by the turn's main action</li>
207
+ <li>the <span class="badge pass">✓ tests pass</span> / <span class="badge fail">✗ tests fail</span> badge is that turn's test result</li>
208
+ <li><span class="bluedot"></span><span id="winLeg"></span></li>
209
+ </ul>
210
+ <div class="tl" id="tl"></div>
211
+ </div>
212
+
213
+ <div id="autonomy" class="hidden"></div>
214
+ </div>
215
+ <script>
216
+ // Synthetic, self-consistent sessions. Everything below is COMPUTED from this
217
+ // data: the panel demonstrates the real logic, exposing nothing real. The three
218
+ // sessions are deliberately contrasting (build / explore / debug) so switching
219
+ // shows distinct fingerprints, archetypes, and top procedures.
220
+ const O="claude-opus-4-8", H="claude-haiku-4-5";
221
+ const DEMO_SESSIONS=[
222
+ {"meta":{"name":"recovered session","client":"Claude Code","project":"local \u00b7 anonymized","id":"ae6d93a7","date":"","intent":"atoms only \u00b7 source not recoverable","illustrative":false,"real":true,"models":[]},"turns":[{"t":"","model":"","prompt":"","plan":"","seq":["edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["other","other","other","read_file","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["other","other","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["other","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["other","read_file","edit","edit","other","read_file","read_file","read_file","read_file","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","read_file","edit","read_file","edit","read_file","edit","other","other","edit","read_file","read_file","read_file","edit","edit","edit","edit","edit","read_file","edit","other","read_file","read_file","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","read_file","edit","other","read_file","other","read_file","read_file","read_file","edit","other","read_file","other","read_file","edit","edit","other","other","other","other","other","other","read_file","read_file","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","other","read_file","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","read_file","edit","read_file","edit","other","read_file","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","other","other","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["other","read_file","read_file","read_file","edit","edit","other","read_file","edit","other","read_file"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["other","other","other","read_file","read_file","other","other","read_file","read_file"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["read_file","edit","read_file","edit","other","read_file","other","other","other","read_file"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["other","other","edit","other","read_file"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","read_file","edit","edit","other","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","read_file","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","read_file","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","other","other","other","read_file","edit","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["read_file","read_file","read_file","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit"]},{"t":"","model":"","prompt":"","plan":"","seq":["read_file","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","other","other","other","other","read_file","read_file","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","edit","edit","other","read_file","other"]},{"t":"","model":"","prompt":"","plan":"","seq":["edit","read_file","edit","other","read_file","other"]}]},
223
+ {meta:{name:"auth-guard", client:"Claude Code", project:"learning-from-dev", id:"ae6d93a7", date:"Jun 17",
224
+ intent:"build a token-validation guard for the auth flow", models:[{name:O},{name:H}]},
225
+ turns:[
226
+ {t:"14:08", model:O, prompt:"explore the auth package layout", plan:"Skim the session store and middleware, then grep for where claims are set.", seq:["read_file","read_file","read_file","read_file","search_repo"]},
227
+ {t:"14:11", model:H, prompt:"how are tokens issued today", plan:"Trace the issue path end to end.", seq:["read_file","read_file","read_file"]},
228
+ {t:"14:13", model:H, prompt:"pull in a jwt library", plan:"Add the dependency and confirm the import resolves.", seq:["package","read_file"]},
229
+ {t:"14:15", model:O, prompt:"scaffold the validation module", plan:"Create validate.py with a stub and import it.", seq:["read_file","edit"]},
230
+ {t:"14:18", model:O, prompt:"add a token validation helper", plan:"validate_token plus a happy-path test.", seq:["read_file","edit","run_test"], outcome:"pass"},
231
+ {t:"14:21", model:O, prompt:"handle the expired-token case", plan:"Branch on expiry and extend the test matrix.", seq:["edit","run_test","edit","run_test"], outcome:"fail"},
232
+ {t:"14:24", model:O, prompt:"the null-subject case still fails", plan:"Guard a missing subject claim before decode.", seq:["read_file","edit","run_test"], outcome:"fail"},
233
+ {t:"14:27", model:O, prompt:"try the library decoder instead", plan:"Swap the hand-rolled parse for the library decoder.", seq:["read_file","edit","run_test"], outcome:"pass"},
234
+ {t:"14:30", model:O, prompt:"add error handling to the auth flow", plan:"Wrap the decode path and surface a typed error.", seq:["read_file","read_file","edit","edit","run_test"], outcome:"fail"},
235
+ {t:"14:33", model:O, prompt:"narrow the caught exception", plan:"Catch only the decode error.", seq:["edit","run_test"], outcome:"fail"},
236
+ {t:"14:35", model:O, prompt:"re-raise as a typed AuthError", plan:"Map to AuthError at the boundary.", seq:["edit","run_test"], outcome:"pass"},
237
+ {t:"14:38", model:O, prompt:"wire the guard into middleware", plan:"Register the guard and read the call site back.", seq:["read_file","edit"]},
238
+ {t:"14:40", model:O, prompt:"logout still errors", plan:"Reproduce the logout failure first.", seq:["read_file","edit","run_test"], outcome:"fail"},
239
+ {t:"14:42", model:O, prompt:"patch the logout path", plan:"Clear the session token on logout.", seq:["edit","run_test"], outcome:"pass"},
240
+ {t:"14:44", model:H, prompt:"lint and tidy the imports", plan:"Run ruff and drop the unused decoder.", seq:["edit","lint"]},
241
+ {t:"14:46", model:O, prompt:"commit the fix", plan:"Stage and commit with a descriptive message.", seq:["version_control"]},
242
+ ]},
243
+ {meta:{name:"ingestion", client:"Claude Code", project:"data-pipeline", id:"7f2c1b04", date:"Jun 16",
244
+ intent:"map how the ingestion pipeline fits together", models:[{name:O},{name:H}]},
245
+ turns:[
246
+ {t:"09:02", model:O, prompt:"where does ingestion start", plan:"Find the entrypoint and the first stage.", seq:["read_file","read_file","read_file","search_repo"]},
247
+ {t:"09:05", model:O, prompt:"trace the queue consumer", plan:"Follow the consumer loop and its handlers.", seq:["read_file","read_file","read_file","read_file"]},
248
+ {t:"09:09", model:H, prompt:"how are batches sized", plan:"Look for the batching policy and limits.", seq:["read_file","read_file","search_repo"]},
249
+ {t:"09:12", model:O, prompt:"find the retry logic", plan:"Search for backoff and retry decorators.", seq:["search_repo","read_file","read_file"]},
250
+ {t:"09:16", model:O, prompt:"look up the config schema", plan:"Open the settings and defaults.", seq:["read_file","read_file","read_file"]},
251
+ {t:"09:19", model:H, prompt:"check dead-letter handling", plan:"Trace where failed messages go.", seq:["read_file","read_file","search_repo"]},
252
+ {t:"09:23", model:O, prompt:"note the backpressure path", plan:"See how the pipeline slows under load.", seq:["read_file","read_file","read_file"]},
253
+ {t:"09:27", model:O, prompt:"skim the tests for coverage", plan:"Scan the test suite for the gaps.", seq:["read_file","read_file","search_repo"]},
254
+ {t:"09:30", model:O, prompt:"summarize the data flow", plan:"Write up the stages end to end.", seq:["read_file","read_file"]},
255
+ ]},
256
+ {meta:{name:"checkout", client:"Claude Code", project:"api-server", id:"c3915d8e", date:"Jun 15",
257
+ intent:"fix the flaky checkout test", models:[{name:O},{name:H}]},
258
+ turns:[
259
+ {t:"16:40", model:O, prompt:"reproduce the flaky checkout test", plan:"Run it in a loop to see it fail.", seq:["read_file","run_test"], outcome:"fail"},
260
+ {t:"16:43", model:O, prompt:"add logging around the race", plan:"Instrument the suspicious async call.", seq:["edit","run_test"], outcome:"fail"},
261
+ {t:"16:46", model:O, prompt:"is it the async timing", plan:"Hypothesize an unawaited settlement.", seq:["edit","run_test"], outcome:"fail"},
262
+ {t:"16:49", model:O, prompt:"await the settlement", plan:"Await the promise before asserting.", seq:["edit","run_test"], outcome:"pass"},
263
+ {t:"16:51", model:H, prompt:"run it again to be sure", plan:"Re-run to confirm it is stable.", seq:["run_test"], outcome:"fail"},
264
+ {t:"16:54", model:O, prompt:"mock the clock", plan:"The remaining flake is wall-clock dependent.", seq:["read_file","edit","run_test"], outcome:"fail"},
265
+ {t:"16:57", model:O, prompt:"freeze time in the fixture", plan:"Pin the clock in the test fixture.", seq:["edit","run_test"], outcome:"pass"},
266
+ {t:"17:00", model:O, prompt:"run the whole suite", plan:"Full pass to check nothing regressed.", seq:["run_test"], outcome:"pass"},
267
+ {t:"17:02", model:H, prompt:"remove the debug logging", plan:"Strip the instrumentation and lint.", seq:["edit","lint"]},
268
+ {t:"17:04", model:O, prompt:"commit the fix", plan:"Commit with a note on the root cause.", seq:["version_control"]},
269
+ ]},
270
+ ];
271
+
272
+ // IS_LOCAL is true when a local runner injected real sessions before this script
273
+ // (examples/procgrep_view.py). On the hosted Space the sessions come from a
274
+ // bundled, atoms-only demo fetched at boot (see the boot block below); until it
275
+ // arrives SESSIONS holds the synthetic DEMO_SESSIONS so the panel still renders.
276
+ let IS_LOCAL=(typeof window!=="undefined"&&Array.isArray(window.PROCGREP_SESSIONS)&&window.PROCGREP_SESSIONS.length>0);
277
+ let SESSIONS=IS_LOCAL?window.PROCGREP_SESSIONS:DEMO_SESSIONS;
278
+ const ORDER=["read_file","search_repo","prompt_ai","edit","lint","run_test","run_code","package","version_control","other"];
279
+ const LAB={read_file:"read_file",search_repo:"search_repo",prompt_ai:"prompt_ai",edit:"edit",lint:"lint",run_test:"run_test",run_code:"run_code",package:"package",version_control:"version_control",other:"bash/other"};
280
+ const COLOR={read_file:"var(--read)",search_repo:"var(--search)",prompt_ai:"var(--prompt)",edit:"var(--edit)",lint:"var(--lint)",run_test:"var(--test)",run_code:"var(--run)",package:"var(--package)",version_control:"var(--vcs)",other:"var(--other)"};
281
+ const WIN=40;
282
+ const modelColors=["#14110E","#A99B86","#5692E5"];
283
+
284
+ // Per-session state, rebuilt by load().
285
+ let META, SESSION, FLAT, RANGE, PRESENT, fills, turnEls;
286
+ let current=0, selected=null, lastNow=null;
287
+ let SESSQ="";
288
+ // Structural query over your own sessions: the same atom-pattern grammar as the
289
+ // eval explorer, run locally on the injected session atoms. Nothing leaves.
290
+ function sessionSpine(s){return s.turns.flatMap(t=>["prompt_ai",...(t.seq||[])]).join(" ")+" ";}
291
+ function sessionRe(){if(!SESSQ.trim())return null;try{return new RegExp(SESSQ);}catch{return false;}}
292
+ function matchedSessions(){const re=sessionRe();return (re===null||re===false)?SESSIONS:SESSIONS.filter(s=>re.test(sessionSpine(s)));}
293
+ function onSessQuery(v){SESSQ=v;renderAutonomy();renderSwitcher();}
294
+ let timer=null, playhead=0, playing=false;
295
+
296
+ const atomsEl=document.getElementById("atoms");
297
+ const tlEl=document.getElementById("tl");
298
+ const divider=document.createElement("div");
299
+ divider.className="winmark";
300
+
301
+ function shares(atoms){const c={};atoms.forEach(a=>c[a]=(c[a]||0)+1);const n=atoms.length||1;
302
+ const s={};PRESENT.forEach(k=>s[k]=(c[k]||0)/n);return s;}
303
+ function dominant(seq){const c={};seq.forEach(a=>c[a]=(c[a]||0)+1);let best="other",bn=-1;
304
+ ORDER.forEach(k=>{if((c[k]||0)>bn){bn=c[k]||0;best=k;}});return bn>0?best:"other";}
305
+ function topProcedure(atoms){
306
+ const pair={};
307
+ for(let i=0;i<atoms.length-1;i++){const k=atoms[i]+" | "+atoms[i+1];pair[k]=(pair[k]||0)+1;}
308
+ let best=null,bn=0;for(const k in pair)if(pair[k]>bn){bn=pair[k];best=k;}
309
+ if(!best)return null;
310
+ const [l,r]=best.split(" | ");
311
+ return {chain:l+" → "+r, weight:bn/Math.max(1,atoms.length-1)};
312
+ }
313
+ function gloss(chain){
314
+ if(chain==="edit → run_test"||chain==="run_test → edit") return "build then verify";
315
+ if(chain==="read_file → edit") return "locate then change";
316
+ if(chain==="read_file → read_file") return "exploration sweep";
317
+ if(chain==="read_file → search_repo"||chain==="search_repo → read_file") return "search and read";
318
+ if(chain==="edit → prompt_ai"||chain==="prompt_ai → edit") return "tight revision loop";
319
+ if(chain==="run_test → run_test") return "re-running tests";
320
+ return "";
321
+ }
322
+ function shortModel(name){return name.replace("claude-","");}
323
+ function primaryModel(turns){
324
+ const c={};turns.forEach(t=>{c[t.model]=(c[t.model]||0)+t.seq.length;});
325
+ return Object.entries(c).sort((a,b)=>b[1]-a[1])[0][0];
326
+ }
327
+ function _mins(t){
328
+ if(!t) return null;
329
+ const [h,m]=t.split(":").map(Number);
330
+ return (Number.isFinite(h)&&Number.isFinite(m)) ? h*60+m : null;
331
+ }
332
+ // Span from the earliest to the latest turn time, not first-to-last: transcript
333
+ // timestamps are not always monotonic, so first-minus-last could go negative.
334
+ // Returns null when there are too few times to span (e.g. an atoms-only session).
335
+ function timeSpan(turns){
336
+ const xs=turns.map(t=>_mins(t.t)).filter(v=>v!=null);
337
+ if(xs.length<2) return null;
338
+ const lo=Math.min(...xs), hi=Math.max(...xs);
339
+ const start=turns.find(t=>_mins(t.t)===lo).t, end=turns.find(t=>_mins(t.t)===hi).t;
340
+ return {start, end, mins:hi-lo};
341
+ }
342
+ // Prefer the real ISO duration the adapter computed (handles multi-day sessions);
343
+ // fall back to the HH:MM span only for the demo, which carries no real timing.
344
+ function durationMin(session){
345
+ const m=session.meta&&session.meta.durationMin;
346
+ if(typeof m==="number") return m;
347
+ const s=timeSpan(session.turns||[]);
348
+ return s?s.mins:null;
349
+ }
350
+ function fmtDur(m){
351
+ if(m==null) return null;
352
+ if(m<90) return m+" min";
353
+ if(m<1440) return Math.round(m/60)+" h";
354
+ return Math.round(m/1440)+" d";
355
+ }
356
+ // Stage, EARNED from the session's own procedure mix -- not hand-labeled.
357
+ // No tests + read/search dominant -> explore; high fail-rate tight loop with
358
+ // little reading -> debug; otherwise edit+test feature work -> build.
359
+ function classifyStage(turns){
360
+ let actions=0,tests=0,fails=0,reads=0;
361
+ turns.forEach(t=>{
362
+ t.seq.forEach(a=>{actions++;if(a==="run_test")tests++;if(a==="read_file"||a==="search_repo")reads++;});
363
+ if(t.outcome==="fail")fails++;
364
+ });
365
+ if(tests===0) return "explore";
366
+ const failRate=turns.length?fails/turns.length:0;
367
+ const readShare=actions?reads/actions:0;
368
+ if(failRate>=0.4 && readShare<0.2) return "debug";
369
+ return "build";
370
+ }
371
+ function colorForModel(name){const i=META.models.findIndex(m=>m.name===name);return modelColors[(i<0?0:i)%modelColors.length];}
372
+
373
+ function renderHeader(){
374
+ document.getElementById("ident").innerHTML=
375
+ `<div class="idrow"><span class="k">platform</span><span class="v">${META.client}</span></div>`+
376
+ `<div class="idrow"><span class="k">workspace</span><span class="v">${META.project}</span></div>`+
377
+ `<div class="idrow"><span class="k">session</span><span class="v hash">${META.id}</span></div>`;
378
+ const itag = META.illustrative!==false ? " illustrative" : (META.promptsParaphrased ? " paraphrased prompts" : "");
379
+ document.getElementById("intent").innerHTML=(META.intent||"")+(itag?`<span class="tag">${itag.trim()}</span>`:"");
380
+ let actions=0;
381
+ SESSION.forEach(t=>{actions+=t.seq.length;});
382
+ const apx=(actions/SESSION.length).toFixed(1);
383
+ const row=(k,v)=>`<div class="idrow"><span class="k">${k}</span><span class="v">${v}</span></div>`;
384
+ let html=(META.date?row("date",META.date):"");
385
+ const dur=durationMin({meta:META,turns:SESSION});
386
+ if(dur!=null) html+=row("duration",fmtDur(dur));
387
+ html+=row("turns",SESSION.length)+row("tool calls",actions)+row("tool calls / prompt",apx);
388
+ document.getElementById("stats").innerHTML=html;
389
+ }
390
+
391
+ function buildAtoms(){
392
+ atomsEl.innerHTML="";fills={};
393
+ PRESENT.forEach(k=>{
394
+ const row=document.createElement("div");row.className="atom";row.dataset.k=k;
395
+ row.innerHTML=`<span class="dot"></span><span class="nm">${LAB[k]}</span>`+
396
+ `<span class="track"><span class="fill" style="background:${COLOR[k]}"></span></span><span class="pc">0%</span>`;
397
+ row.onclick=()=>toggleFilter(k);
398
+ atomsEl.appendChild(row);
399
+ fills[k]={fill:row.querySelector(".fill"),pc:row.querySelector(".pc")};
400
+ });
401
+ }
402
+
403
+ function childrenHtml(tn){
404
+ const runs=[];let i=0;
405
+ while(i<tn.seq.length){let j=i;while(j<tn.seq.length&&tn.seq[j]===tn.seq[i])j++;runs.push([tn.seq[i],j-i]);i=j;}
406
+ return runs.map(([a,n],idx)=>{
407
+ const last=idx===runs.length-1, name=a==="other"?"bash":a;
408
+ let badge="";
409
+ if(last&&tn.outcome==="pass")badge=` <span class="badge pass">✓ tests pass</span>`;
410
+ if(last&&tn.outcome==="fail")badge=` <span class="badge fail">✗ tests fail</span>`;
411
+ return `<div class="act"><span class="br">${last?"└─":"├─"}</span><span style="color:${COLOR[a]}">${name}${n>1?" × "+n:""}</span>${badge}</div>`;
412
+ }).join("");
413
+ }
414
+ function buildTimeline(){
415
+ tlEl.innerHTML="";turnEls=[];
416
+ SESSION.forEach((tn,i)=>{
417
+ const turnNo=i+1;
418
+ const d=document.createElement("div");
419
+ d.className="turn";
420
+ d.dataset.idx=turnNo-1;
421
+ d.dataset.atoms=[...new Set(tn.seq)].join(",");
422
+ d.innerHTML=`<span class="node" style="background:${COLOR[dominant(tn.seq)]}"></span>`+
423
+ `<div class="turnmain">`+
424
+ `<div class="when">Turn ${turnNo} · <b>${tn.t}</b><span class="mtag" style="color:${colorForModel(tn.model)}">${shortModel(tn.model)}</span></div>`+
425
+ (tn.prompt?`<div class="pr-count">prompt · ${tn.prompt.length} chars</div><div class="pr-text">"${tn.prompt}"</div>`:"")+
426
+ `<div class="acts">${childrenHtml(tn)}</div>`+
427
+ `</div>`+
428
+ `<div class="plan">${tn.plan}</div>`;
429
+ d.onclick=()=>{if(playing)pause(false);};
430
+ tlEl.appendChild(d);
431
+ turnEls[turnNo-1]=d;
432
+ });
433
+ }
434
+
435
+ function setPlayhead(p, scroll){
436
+ const lo=Math.max(0,p-WIN);
437
+ const win=FLAT.slice(lo,p);
438
+ const sh=shares(win);
439
+ PRESENT.forEach(k=>{fills[k].fill.style.width=(sh[k]*100)+"%";fills[k].pc.textContent=Math.round(sh[k]*100)+"%";});
440
+ const proc=topProcedure(win);
441
+ if(proc){
442
+ document.getElementById("procChain").textContent=proc.chain;
443
+ document.getElementById("procW").textContent=Math.round(proc.weight*100)+"% of steps";
444
+ const g=gloss(proc.chain);
445
+ document.getElementById("procGloss").textContent=g?` · ${g}`:"";
446
+ }
447
+ let nowEl=null, firstInwin=null, hasPast=false;
448
+ for(let i=0;i<SESSION.length;i++){
449
+ const {s,e}=RANGE[i], el=turnEls[i];
450
+ let zone;
451
+ if(s>=p) zone="future";
452
+ else if(s<p && p<=e) zone="now";
453
+ else if(e>lo && s<p) zone="inwin";
454
+ else zone="past";
455
+ el.className="turn"+(zone==="future"?" future":zone==="now"?" now inwin":zone==="inwin"?" inwin":"");
456
+ if(zone==="now") nowEl=el;
457
+ if((zone==="inwin"||zone==="now") && !firstInwin) firstInwin=el;
458
+ if(zone==="past") hasPast=true;
459
+ }
460
+ if(firstInwin && hasPast) tlEl.insertBefore(divider, firstInwin); else if(divider.parentNode) divider.remove();
461
+ // Scroll ONLY the timeline container, never the page, so the reader can
462
+ // scroll the page freely during replay.
463
+ if(scroll && nowEl && nowEl!==lastNow){
464
+ const tr=nowEl.getBoundingClientRect(), cr=tlEl.getBoundingClientRect();
465
+ if(tr.top < cr.top) tlEl.scrollTop += tr.top - cr.top - 10;
466
+ else if(tr.bottom > cr.bottom) tlEl.scrollTop += tr.bottom - cr.bottom + 10;
467
+ }
468
+ lastNow=nowEl;
469
+ }
470
+
471
+ function toggleFilter(k){if(playing)pause(false);selected=selected===k?null:k;applyFilter();}
472
+ function clearFilter(){selected=null;applyFilter();}
473
+ function applyFilter(){
474
+ document.querySelectorAll(".atom").forEach(r=>r.classList.toggle("sel",r.dataset.k===selected));
475
+ const note=document.getElementById("fnote");
476
+ note.innerHTML = selected
477
+ ? `showing turns that used <b>${LAB[selected]}</b> · <a onclick="clearFilter()">show all</a>` : "";
478
+ let firstMatch=null;
479
+ turnEls.forEach(t=>{
480
+ const has=!selected || (t.dataset.atoms||"").split(",").includes(selected);
481
+ t.classList.toggle("dim",!has);
482
+ if(has && selected && !firstMatch && !t.classList.contains("future")) firstMatch=t;
483
+ });
484
+ if(firstMatch){
485
+ const tr=firstMatch.getBoundingClientRect(), cr=tlEl.getBoundingClientRect();
486
+ tlEl.scrollTop += tr.top - cr.top - 10;
487
+ }
488
+ }
489
+ function closeTip(){document.getElementById("tip").classList.add("hidden");}
490
+ // Privacy dial: "atoms only" hides prompt + plan text (what to_shareable exports);
491
+ // "prompts shown" is the local view. (--paraphrase is the runner's middle ground.)
492
+ // One toggle: pressed (on) = prompt text is shown, unpressed = hidden.
493
+ function togglePriv(){
494
+ const showing=document.body.classList.toggle("pmode-shown");
495
+ document.body.classList.toggle("pmode-counts",!showing);
496
+ document.getElementById("privtog").classList.toggle("on",showing);
497
+ }
498
+
499
+ // ---- replay ----
500
+ const btn=document.getElementById("replayBtn"), tri=btn.querySelector(".tri"), rlab=document.getElementById("rlab");
501
+ function setBtn(state){
502
+ if(state==="playing"){tri.textContent="⏸";rlab.textContent="Pause";}
503
+ else if(state==="paused"){tri.textContent="▶";rlab.textContent="Resume";}
504
+ else {tri.textContent="▶";rlab.textContent="Replay session";}
505
+ }
506
+ function pause(ended){playing=false;if(timer){clearInterval(timer);timer=null;}setBtn(ended?"ended":"paused");}
507
+ function play(){
508
+ if(playing)return;
509
+ clearFilter();
510
+ if(playhead>=FLAT.length)playhead=1;
511
+ playing=true;setBtn("playing");
512
+ if(timer)clearInterval(timer);
513
+ timer=setInterval(()=>{
514
+ setPlayhead(playhead, true);
515
+ if(playhead>=FLAT.length){pause(true);return;}
516
+ playhead++;
517
+ },150);
518
+ }
519
+ function toggleReplay(){playing?pause(false):play();}
520
+
521
+ // ---- session switcher ----
522
+ const TAGS={
523
+ build:"writing then verifying code; edit and run_test dominate",
524
+ explore:"reading and searching to understand code; few edits, no tests",
525
+ debug:"repeated edit then run_test loops, often failing before a pass",
526
+ };
527
+ function renderSwitcher(){
528
+ const ov=document.getElementById("overviewNav");
529
+ if(ov){ov.innerHTML="";
530
+ if(IS_LOCAL){
531
+ const b=document.createElement("button");
532
+ b.innerHTML=
533
+ '<span class="ovrow"><svg class="ovico" width="15" height="12" viewBox="0 0 15 12" aria-hidden="true">'
534
+ +'<rect x="0" y="7" width="2.6" height="5"/><rect x="4" y="4" width="2.6" height="8"/>'
535
+ +'<rect x="8" y="6" width="2.6" height="6"/><rect x="12" y="1" width="2.6" height="11"/></svg>'
536
+ +'<span class="nnm">overview</span></span>'
537
+ +'<span class="nmeta">run length across sessions</span>';
538
+ b.onclick=()=>{if(playing)pause(false);setView("overview");};
539
+ ov.appendChild(b);
540
+ }
541
+ }
542
+ const el=document.getElementById("switch");el.innerHTML="";
543
+ const matched=new Set(matchedSessions());
544
+ SESSIONS.forEach((s,i)=>{
545
+ const b=document.createElement("button");
546
+ if(i===current)b.className="active";
547
+ if(SESSQ.trim()&&!matched.has(s))b.classList.add("hidden"); // query filters the rail too
548
+ const stage=classifyStage(s.turns);
549
+ const dur=durationMin(s), pm=primaryModel(s.turns);
550
+ b.innerHTML=`<span class="nnm">${s.meta.name}</span>`+
551
+ `<span class="nmeta">${s.meta.project}${s.meta.date?` · ${s.meta.date}`:''}${dur!=null?` · ${fmtDur(dur)}`:''}</span>`+
552
+ `<span class="nmeta">${s.meta.client}${pm?` · ${shortModel(pm)}`:''}</span>`;
553
+ if(TAGS[stage]) b.title=`${stage}: ${TAGS[stage]}`;
554
+ b.onclick=()=>load(i);
555
+ el.appendChild(b);
556
+ });
557
+ }
558
+
559
+ // Aggregate view: run-length is the agent actions after each human prompt, i.e.
560
+ // the length of each turn's seq. The histogram is computed from the same
561
+ // injected sessions that power the per-session replay; no extra data path.
562
+ function renderAutonomy(){
563
+ const au=document.getElementById("autonomy");
564
+ // Build the query bar once and keep it; only the chart below re-renders, so
565
+ // typing in the query never loses focus.
566
+ if(!document.getElementById("sq")){
567
+ au.innerHTML='<div class="sqbar"><span>⌕</span><input id="sq" autocomplete="off" '
568
+ +'placeholder="grep your sessions · atom pattern, e.g. (read_file ){3,}" oninput="onSessQuery(this.value)"></div>'
569
+ +'<div class="sqnote" id="sqnote"></div><div id="autochart"></div>';
570
+ document.getElementById("sq").value=SESSQ;
571
+ }
572
+ const matched=matchedSessions();
573
+ const runs=[]; matched.forEach(s=>s.turns.forEach(t=>{if(Array.isArray(t.seq))runs.push(t.seq.length);}));
574
+ const bad=sessionRe()===false;
575
+ document.getElementById("sqnote").innerHTML = SESSQ.trim()
576
+ ? `${matched.length} / ${SESSIONS.length} sessions match`+(bad?' · <span style="color:var(--edit)">invalid pattern</span>':"")
577
+ : `${SESSIONS.length} session${SESSIONS.length>1?"s":""}`;
578
+ const chart=document.getElementById("autochart");
579
+ if(!runs.length){chart.innerHTML='<p class="cap2">no matching runs</p>';return;}
580
+ const W=5, top=Math.max(...runs);
581
+ const sorted=[...runs].sort((a,b)=>a-b);
582
+ const median=sorted[Math.floor((sorted.length-1)/2)];
583
+ const mean=runs.reduce((a,b)=>a+b,0)/runs.length;
584
+ const p95=sorted[Math.min(sorted.length-1,Math.floor(sorted.length*0.95))];
585
+ const cap=Math.max(W*4,Math.ceil(p95/W)*W), clipped=cap<top;
586
+ const nb=cap/W+1, counts=new Array(nb).fill(0);
587
+ runs.forEach(r=>counts[Math.min(Math.floor(r/W),nb-1)]++);
588
+ const SW=720,SH=300,ml=44,mr=14,mt=20, pw=SW-ml-mr, ph=SH-mt-44;
589
+ const xmax=nb*W, bw=pw/nb, ymax=Math.max(...counts);
590
+ const xpx=v=>ml+(v/xmax)*pw, ypx=c=>mt+ph-(c/ymax)*ph;
591
+ let bars="";
592
+ counts.forEach((c,i)=>{if(!c)return;const x=ml+i*bw,h=(c/ymax)*ph;
593
+ bars+=`<rect x="${x.toFixed(1)}" y="${(mt+ph-h).toFixed(1)}" width="${(bw-0.6).toFixed(1)}" height="${h.toFixed(1)}" fill="var(--edit)"/>`;});
594
+ let yt="";const stepY=[1,2,5,10,20,50,100,200,500,1000].find(s=>ymax/s<=4)||2000;
595
+ for(let v=0;v<=ymax;v+=stepY){const y=ypx(v);
596
+ yt+=`<text x="${ml-9}" y="${(y+3).toFixed(0)}" text-anchor="end" font-size="10" fill="var(--mut)">${v}</text>`
597
+ +`<line x1="${ml-5}" y1="${y.toFixed(1)}" x2="${ml}" y2="${y.toFixed(1)}" stroke="var(--line)" stroke-width="1"/>`;}
598
+ let xt="";const step=cap<=30?5:(cap<=80?10:25);
599
+ for(let v=0;v<=cap;v+=step){const x=xpx(v);const lab=(v===cap&&clipped)?`${v}+`:`${v}`;
600
+ xt+=`<text x="${x.toFixed(1)}" y="${(mt+ph+17).toFixed(0)}" text-anchor="middle" font-size="10" fill="var(--mut)">${lab}</text>`;}
601
+ const base=`<line x1="${ml}" y1="${(mt+ph).toFixed(1)}" x2="${SW-mr}" y2="${(mt+ph).toFixed(1)}" stroke="var(--line)" stroke-width="1"/>`;
602
+ const svg=`<svg viewBox="0 0 ${SW} ${SH}" width="100%" role="img" aria-label="Actions per human prompt">${bars}${base}${yt}${xt}`
603
+ +`<text x="${ml+pw/2}" y="${SH-6}" text-anchor="middle" font-size="11" fill="var(--mut)">actions after one prompt</text></svg>`;
604
+ const st=(v,l)=>`<div class="stat"><div class="sv">${v}</div><div class="sl">${l}</div></div>`;
605
+ chart.innerHTML=`<p class="cap">Actions per human prompt <span class="hint">· across ${matched.length} session${matched.length>1?"s":""}</span></p>`
606
+ +`<div class="chart">${svg}</div><p class="cap2">histogram of agent run lengths between prompts</p>`
607
+ +`<div class="astats">${st(matched.length,"sessions")}${st(runs.length,"runs")}${st(median,"median run")}${st(mean.toFixed(1),"mean run")}${st(top,"longest run")}</div>`;
608
+ }
609
+
610
+ function setView(v){
611
+ const det=document.getElementById("detail"), au=document.getElementById("autonomy");
612
+ const overview=v==="overview";
613
+ det.classList.toggle("hidden",overview);
614
+ au.classList.toggle("hidden",!overview);
615
+ document.querySelectorAll("#overviewNav button").forEach(b=>b.classList.toggle("active",overview));
616
+ // Only one thing is active: the overview, or the current session -- never both.
617
+ document.querySelectorAll("#switch button").forEach((b,i)=>b.classList.toggle("active",!overview&&i===current));
618
+ }
619
+
620
+ function load(idx){
621
+ if(timer){clearInterval(timer);timer=null;}
622
+ setView("detail");
623
+ current=idx;
624
+ META=SESSIONS[idx].meta;
625
+ SESSION=SESSIONS[idx].turns;
626
+ FLAT=[];RANGE=[];
627
+ SESSION.forEach(tn=>{const s=FLAT.length;FLAT.push("prompt_ai");tn.seq.forEach(a=>FLAT.push(a));RANGE.push({s,e:FLAT.length});});
628
+ PRESENT=ORDER.filter(k=>k==="prompt_ai"||SESSION.some(t=>t.seq.includes(k)));
629
+ selected=null;lastNow=null;playing=false;playhead=FLAT.length;
630
+ renderSwitcher();
631
+ renderHeader();
632
+ buildAtoms();
633
+ buildTimeline();
634
+ document.getElementById("atomsHint").textContent= FLAT.length>WIN ? `· last ${WIN} of ${FLAT.length} atoms` : `· ${FLAT.length} atoms`;
635
+ document.getElementById("winLeg").textContent=` = inside the ${WIN}-atom fingerprint window`;
636
+ divider.textContent=`earlier · outside the ${WIN}-atom window`;
637
+ play();
638
+ }
639
+
640
+ // When embedded in the explorer, the explorer's sidebar is the nav: hide our own
641
+ // top bar AND rail, and use the full width -- the parent lists the sessions.
642
+ const PARAMS=new URLSearchParams(location.search);
643
+ const EMBED=PARAMS.has("embed");
644
+ // On the hosted Space the parent asks for the bundled demo (demo_session.json):
645
+ // one anonymized, atoms-only session exported through to_shareable. It carries no
646
+ // prompt text, code, or paths, so it is safe to ship.
647
+ const WANT_DEMO=PARAMS.has("demo");
648
+ if(EMBED){
649
+ const tb=document.querySelector(".topbar"); if(tb)tb.style.display="none";
650
+ const nv=document.querySelector(".nav"); if(nv)nv.style.display="none";
651
+ document.body.style.padding="22px 24px 40px";
652
+ }
653
+
654
+ // Was the panel handed real session data (local runner or the bundled demo),
655
+ // as opposed to the synthetic walkthrough? Drives the run-length overview and
656
+ // dropping the standalone site links. Set true when the demo loads.
657
+ let HAS_REAL=IS_LOCAL;
658
+ // Show the run-length overview as the landing view only when there are several
659
+ // sessions to aggregate; a single bundled demo lands on its own detail instead.
660
+ let SHOW_OVERVIEW=IS_LOCAL;
661
+
662
+ // Boot once SESSIONS is final. Kept in a function so the bundled demo can be
663
+ // fetched first without blocking parse.
664
+ function boot(){
665
+ // Newest session first when a recency key is present; stable, so the demo
666
+ // (no `ended`) keeps its authored order.
667
+ SESSIONS.sort((a,b)=>String(b.meta.ended||"").localeCompare(String(a.meta.ended||"")));
668
+ // The local runner opens this file from a temp dir, so the relative site links
669
+ // (essay, explorer) cannot resolve -- drop them; the local panel stands alone.
670
+ if(HAS_REAL){document.querySelectorAll(".topnav a").forEach(a=>a.remove());}
671
+ load(0);
672
+ if(SHOW_OVERVIEW){renderAutonomy();setView("overview");}
673
+ // Embedded: hand the session list (metadata only) to the explorer so it can show
674
+ // them in the global rail, and take selection commands back. One rail, not two.
675
+ if(EMBED && window.parent!==window){
676
+ const list=SESSIONS.map((s,i)=>({i,name:s.meta.name,client:s.meta.client,
677
+ date:s.meta.date||"",dur:fmtDur(durationMin(s))||"",model:shortModel(primaryModel(s.turns))||""}));
678
+ window.parent.postMessage({type:"procgrep-sessions",list,hasOverview:SHOW_OVERVIEW},"*");
679
+ window.addEventListener("message",e=>{
680
+ const m=e.data; if(!m||m.type!=="procgrep-select")return;
681
+ if(playing)pause(false);
682
+ if(m.index==null)setView("overview"); else load(m.index);
683
+ });
684
+ }
685
+ }
686
+
687
+ if(WANT_DEMO && !IS_LOCAL){
688
+ fetch("demo_session.json").then(r=>r.json()).then(d=>{
689
+ const arr=Array.isArray(d)?d:[d];
690
+ if(arr.length){SESSIONS=arr;IS_LOCAL=true;HAS_REAL=true;SHOW_OVERVIEW=arr.length>1;}
691
+ }).catch(()=>{}).finally(boot);
692
+ }else{
693
+ boot();
694
+ }
695
+ </script>
696
+ </body>
697
+ </html>
static/theme.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* procgrep shared palette: the single source of truth for the base tokens used
2
+ across the essay, explorer, and session panel. Page-specific tokens (the
3
+ panel's atom and outcome colors, its lighter rule shade) stay with the page
4
+ that uses them and alias these where they match. */
5
+ :root{
6
+ --paper:#F7F5F2;
7
+ --ink:#14110E;
8
+ --copper:#CB4D20;
9
+ --blue:#5692E5;
10
+ --teal:#20A380;
11
+ --olive:#585E53;
12
+ --rule:#d9d4cc;
13
+ --gray:#b7b1a7;
14
+ }