@oratis/lisa 0.2.0 → 0.3.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.
Files changed (55) hide show
  1. package/README.md +70 -6
  2. package/README.zh-CN.md +69 -6
  3. package/completions/_lisa +1 -0
  4. package/completions/lisa.bash +1 -1
  5. package/completions/lisa.fish +1 -0
  6. package/dist/agent.d.ts.map +1 -1
  7. package/dist/agent.js +12 -0
  8. package/dist/agent.js.map +1 -1
  9. package/dist/cli.js +23 -0
  10. package/dist/cli.js.map +1 -1
  11. package/dist/env.js +6 -1
  12. package/dist/env.js.map +1 -1
  13. package/dist/heartbeat/config.d.ts.map +1 -1
  14. package/dist/heartbeat/config.js +7 -1
  15. package/dist/heartbeat/config.js.map +1 -1
  16. package/dist/heartbeat/install.d.ts.map +1 -1
  17. package/dist/heartbeat/install.js +80 -15
  18. package/dist/heartbeat/install.js.map +1 -1
  19. package/dist/integrations/claude-code/parser.d.ts +56 -0
  20. package/dist/integrations/claude-code/parser.d.ts.map +1 -0
  21. package/dist/integrations/claude-code/parser.js +224 -0
  22. package/dist/integrations/claude-code/parser.js.map +1 -0
  23. package/dist/integrations/claude-code/watcher.d.ts +127 -0
  24. package/dist/integrations/claude-code/watcher.d.ts.map +1 -0
  25. package/dist/integrations/claude-code/watcher.js +361 -0
  26. package/dist/integrations/claude-code/watcher.js.map +1 -0
  27. package/dist/llm.d.ts +0 -6
  28. package/dist/llm.d.ts.map +1 -1
  29. package/dist/llm.js +0 -10
  30. package/dist/llm.js.map +1 -1
  31. package/dist/mood-bus.d.ts +11 -2
  32. package/dist/mood-bus.d.ts.map +1 -1
  33. package/dist/mood-bus.js +15 -2
  34. package/dist/mood-bus.js.map +1 -1
  35. package/dist/sessions/store.d.ts +1 -5
  36. package/dist/sessions/store.d.ts.map +1 -1
  37. package/dist/sessions/store.js +0 -11
  38. package/dist/sessions/store.js.map +1 -1
  39. package/dist/tools/task.d.ts +0 -1
  40. package/dist/tools/task.d.ts.map +1 -1
  41. package/dist/tools/task.js +0 -3
  42. package/dist/tools/task.js.map +1 -1
  43. package/dist/web/assets/lisa-mascot.png +0 -0
  44. package/dist/web/island.d.ts +12 -0
  45. package/dist/web/island.d.ts.map +1 -0
  46. package/dist/web/island.js +927 -0
  47. package/dist/web/island.js.map +1 -0
  48. package/dist/web/lisa-html.d.ts +29 -0
  49. package/dist/web/lisa-html.d.ts.map +1 -0
  50. package/dist/web/lisa-html.js +2095 -0
  51. package/dist/web/lisa-html.js.map +1 -0
  52. package/dist/web/server.d.ts.map +1 -1
  53. package/dist/web/server.js +86 -1601
  54. package/dist/web/server.js.map +1 -1
  55. package/package.json +11 -1
@@ -0,0 +1,2095 @@
1
+ /**
2
+ * Lisa.app chat HTML — the main /web shell.
3
+ *
4
+ * Extracted out of server.ts so the visual layer (CSS + body markup +
5
+ * client JS) can evolve as one piece without bloating the server module.
6
+ *
7
+ * Design language follows reference/mockups/lisa-app-redesign.html:
8
+ * - Glass-morphism dark UI with cyan (#6ad4ff) brand accent
9
+ * - 280px sidebar (identity card · currently wanting · Claude monitor ·
10
+ * last reflection · SOUL/SKILLS/MEMORY/TOOLS row · session badge)
11
+ * - Right pane: chat log + composer
12
+ *
13
+ * IDs preserved from the previous pixel-art shell so the existing
14
+ * client-side JS (history loading, mood updates, modal panels, birth
15
+ * ritual, cfg gate, attachments, send + SSE streaming) keeps working
16
+ * unchanged:
17
+ * log, input, form, sendBtn, sessionId, fileInput, attachPreview,
18
+ * mascot, mascotTag, modalBg, modalTitle, modalBody, modalClose,
19
+ * cfgOverlay, cfgForm, cfgAnthropic, cfgOpenai, cfgSave, cfgError,
20
+ * birthOverlay, birthSteps, birthFinal, birthEnter, birthError,
21
+ * attachBtn
22
+ *
23
+ * New IDs for the sidebar live blocks (wired in the trailing
24
+ * "sidebar live wiring" script section):
25
+ * identitySub, sbDesire, sbClaudeCard, sbClaudeCount, sbClaudeRows,
26
+ * sbReflection, sbReflectionBody, sbSessionBadge
27
+ */
28
+ export const MAIN_HTML = `<!doctype html>
29
+ <html lang="en"><head>
30
+ <meta charset="utf-8">
31
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
32
+ <title>LISA</title>
33
+ <link rel="manifest" href="/manifest.webmanifest">
34
+ <meta name="theme-color" content="#07091a">
35
+ <meta name="apple-mobile-web-app-capable" content="yes">
36
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
37
+ <meta name="apple-mobile-web-app-title" content="LISA">
38
+ <link rel="apple-touch-icon" href="/assets/lisa-mascot.png">
39
+ <link rel="icon" type="image/png" href="/assets/lisa-mascot.png">
40
+ <style>
41
+ :root {
42
+ color-scheme: dark;
43
+
44
+ /* New design tokens (mockup) */
45
+ --accent: #6ad4ff;
46
+ --accent-soft: rgba(106, 212, 255, 0.13);
47
+ --accent-glow: rgba(106, 212, 255, 0.27);
48
+ --warm: #ffd066;
49
+ --dream: #b487ff;
50
+ --claude: #ff8c42;
51
+ --err-color: #ff5577;
52
+
53
+ --bg-deep: #07091a;
54
+ --bg-1: #0b1024;
55
+ --bg-2: #11163a;
56
+ --bg-3: #1a1f4a;
57
+ --bg-card: rgba(20, 26, 64, 0.65);
58
+ --bg-card-strong: rgba(20, 26, 64, 0.88);
59
+ --border-new: rgba(255, 255, 255, 0.07);
60
+ --border-strong: rgba(255, 255, 255, 0.14);
61
+
62
+ --fg: #e8eaff;
63
+ --fg-2: #aeb5d3;
64
+ --fg-3: #6c7398;
65
+ --fg-faint: #444a6e;
66
+
67
+ /* Legacy tokens — kept so the unchanged modal / cfg / birth
68
+ overlay styles below still resolve. The new shell + chat use
69
+ the modern tokens above. */
70
+ --bg: #0a0d2b;
71
+ --panel: #1a1f4d;
72
+ --panel-light: #2a3270;
73
+ --border: #6a7ad9;
74
+ --border-light: #a4b2ff;
75
+ --text: #e7ecff;
76
+ --text-dim: #8090c0;
77
+ --you: #6cf6e1;
78
+ --lisa: #ffd167;
79
+ --tool: #ff7eb6;
80
+ --error: #ff5577;
81
+ }
82
+ * { box-sizing: border-box; }
83
+ html, body {
84
+ height: 100%;
85
+ margin: 0;
86
+ background: #000;
87
+ font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
88
+ -webkit-font-smoothing: antialiased;
89
+ color: var(--fg);
90
+ overflow: hidden;
91
+ }
92
+
93
+ /* ── App shell ─────────────────────────────────────────────── */
94
+ .frame {
95
+ height: 100vh;
96
+ width: 100vw;
97
+ display: grid;
98
+ grid-template-columns: 280px 1fr;
99
+ grid-template-rows: 36px 1fr;
100
+ grid-template-areas:
101
+ "titlebar titlebar"
102
+ "sidebar main";
103
+ background:
104
+ radial-gradient(ellipse at 30% 20%, #1a1238 0%, transparent 50%),
105
+ radial-gradient(ellipse at 80% 70%, #0a1f3a 0%, transparent 60%),
106
+ linear-gradient(180deg, var(--bg-1) 0%, var(--bg-deep) 100%);
107
+ overflow: hidden;
108
+ }
109
+
110
+ /* Title bar — visually shows "Lisa · session-id". The actual drag
111
+ behavior is handled Swift-side by a transparent NSView overlay
112
+ (DragHandleView) placed on top of the WKWebView for the same 36pt
113
+ strip — WebKit ignores the CSS -webkit-app-region: drag property,
114
+ so the cosmetic HTML and the functional drag region are two
115
+ separate things.
116
+ Padding-left reserves the ~78pt that the macOS traffic-light
117
+ buttons occupy at top-left. */
118
+ .titlebar {
119
+ grid-area: titlebar;
120
+ background: rgba(7, 9, 26, 0.55);
121
+ backdrop-filter: blur(20px);
122
+ -webkit-backdrop-filter: blur(20px);
123
+ border-bottom: 1px solid var(--border-new);
124
+ display: flex;
125
+ align-items: center;
126
+ justify-content: center;
127
+ padding: 0 14px 0 78px;
128
+ font-size: 12px;
129
+ font-weight: 600;
130
+ letter-spacing: 0.04em;
131
+ color: var(--fg-2);
132
+ /* nothing here should ever capture pointer events — the NSView
133
+ overlay above handles dragging, and there are no interactive
134
+ elements in the HTML titlebar. */
135
+ user-select: none;
136
+ pointer-events: none;
137
+ }
138
+ .titlebar .session-tag {
139
+ color: var(--fg-3);
140
+ font-weight: 400;
141
+ margin-left: 6px;
142
+ font-family: ui-monospace, "SF Mono", Menlo, monospace;
143
+ font-size: 11px;
144
+ letter-spacing: 0;
145
+ }
146
+
147
+ /* ── Sidebar ───────────────────────────────────────────────── */
148
+ .sidebar {
149
+ grid-area: sidebar;
150
+ background: rgba(7, 9, 26, 0.4);
151
+ backdrop-filter: blur(30px);
152
+ -webkit-backdrop-filter: blur(30px);
153
+ border-right: 1px solid var(--border-new);
154
+ overflow-y: auto;
155
+ padding: 20px 16px 16px;
156
+ display: flex;
157
+ flex-direction: column;
158
+ gap: 18px;
159
+ }
160
+
161
+ /* Identity card */
162
+ .identity {
163
+ display: grid;
164
+ grid-template-columns: 56px 1fr;
165
+ gap: 12px;
166
+ align-items: center;
167
+ padding: 12px;
168
+ background: var(--bg-card);
169
+ border: 1px solid var(--border-new);
170
+ border-radius: 14px;
171
+ }
172
+ .identity .avatar-wrap {
173
+ width: 56px;
174
+ height: 56px;
175
+ border-radius: 50%;
176
+ position: relative;
177
+ border: 1px solid var(--border-strong);
178
+ box-shadow: 0 0 0 3px var(--accent-soft);
179
+ background: #15192a;
180
+ }
181
+ .identity .avatar-wrap img {
182
+ width: 100%;
183
+ height: 100%;
184
+ border-radius: 50%;
185
+ object-fit: cover;
186
+ object-position: 50% 22%;
187
+ image-rendering: pixelated;
188
+ display: block;
189
+ transition: opacity 250ms ease;
190
+ user-select: none;
191
+ -webkit-user-drag: none;
192
+ }
193
+ .identity .avatar-wrap img.fading { opacity: 0; }
194
+ .identity .avatar-wrap::after {
195
+ content: "";
196
+ position: absolute;
197
+ right: -2px;
198
+ bottom: -2px;
199
+ width: 14px;
200
+ height: 14px;
201
+ border-radius: 50%;
202
+ background: #4ade80;
203
+ border: 2px solid var(--bg-1);
204
+ }
205
+ .identity h1 {
206
+ margin: 0 0 2px;
207
+ font-size: 15px;
208
+ font-weight: 700;
209
+ letter-spacing: 0.02em;
210
+ color: var(--fg);
211
+ }
212
+ .identity .sub {
213
+ margin: 0;
214
+ font-size: 11px;
215
+ color: var(--fg-3);
216
+ }
217
+ .identity .mood {
218
+ display: inline-flex;
219
+ align-items: center;
220
+ gap: 5px;
221
+ margin-top: 4px;
222
+ font-size: 10.5px;
223
+ color: var(--accent);
224
+ text-transform: uppercase;
225
+ letter-spacing: 0.08em;
226
+ font-weight: 600;
227
+ }
228
+ .identity .mood::before {
229
+ content: "";
230
+ width: 6px;
231
+ height: 6px;
232
+ border-radius: 50%;
233
+ background: var(--accent);
234
+ box-shadow: 0 0 6px var(--accent-glow);
235
+ }
236
+
237
+ /* Sidebar plain text section ("currently wanting") */
238
+ .sb-section { display: flex; flex-direction: column; gap: 6px; }
239
+ .sb-section h2 {
240
+ margin: 0 0 2px;
241
+ font-size: 10.5px;
242
+ font-weight: 700;
243
+ text-transform: uppercase;
244
+ letter-spacing: 0.10em;
245
+ color: var(--fg-3);
246
+ padding-left: 4px;
247
+ }
248
+ .sb-section .body-text {
249
+ margin: 0;
250
+ font-size: 12px;
251
+ line-height: 1.55;
252
+ color: var(--fg-2);
253
+ padding: 0 4px;
254
+ }
255
+
256
+ /* Live mini-cards (Claude monitor / last reflection) */
257
+ .card {
258
+ background: var(--bg-card);
259
+ border: 1px solid var(--border-new);
260
+ border-radius: 12px;
261
+ padding: 10px 12px;
262
+ font-size: 12px;
263
+ color: var(--fg-2);
264
+ line-height: 1.5;
265
+ }
266
+ .card.tint-claude {
267
+ border-color: rgba(255, 140, 66, 0.20);
268
+ background: linear-gradient(180deg, rgba(255, 140, 66, 0.06), rgba(255, 140, 66, 0.02));
269
+ }
270
+ .card.tint-idle {
271
+ border-color: rgba(255, 208, 102, 0.22);
272
+ background: linear-gradient(180deg, rgba(255, 208, 102, 0.07), rgba(255, 208, 102, 0.02));
273
+ }
274
+ .card .h {
275
+ display: flex;
276
+ justify-content: space-between;
277
+ align-items: center;
278
+ margin-bottom: 4px;
279
+ }
280
+ .card .h .left {
281
+ display: flex;
282
+ align-items: center;
283
+ gap: 6px;
284
+ font-size: 10.5px;
285
+ font-weight: 700;
286
+ text-transform: uppercase;
287
+ letter-spacing: 0.10em;
288
+ color: var(--claude);
289
+ }
290
+ .card.tint-idle .h .left { color: var(--warm); }
291
+ .card .h .count {
292
+ background: rgba(255, 140, 66, 0.16);
293
+ color: var(--claude);
294
+ font-size: 11px;
295
+ font-weight: 600;
296
+ padding: 2px 7px;
297
+ border-radius: 8px;
298
+ }
299
+ .card.tint-idle .h .count {
300
+ background: rgba(255, 208, 102, 0.16);
301
+ color: var(--warm);
302
+ }
303
+ .session-row {
304
+ display: grid;
305
+ grid-template-columns: 7px 1fr auto;
306
+ align-items: center;
307
+ gap: 7px;
308
+ padding: 5px 0;
309
+ font-size: 11.5px;
310
+ border-top: 1px dashed rgba(255, 140, 66, 0.10);
311
+ cursor: default;
312
+ }
313
+ .session-row:first-of-type { border-top: 0; }
314
+ .session-row .pip {
315
+ width: 7px;
316
+ height: 7px;
317
+ border-radius: 50%;
318
+ background: var(--fg-faint);
319
+ }
320
+ .session-row .pip.working { background: var(--claude); animation: pulse 1.8s ease-in-out infinite; }
321
+ .session-row .pip.waiting { background: var(--claude); }
322
+ .session-row .pip.error { background: var(--err-color); }
323
+ .session-row .name {
324
+ color: var(--fg);
325
+ font-weight: 600;
326
+ overflow: hidden;
327
+ white-space: nowrap;
328
+ text-overflow: ellipsis;
329
+ }
330
+ .session-row .when {
331
+ color: var(--fg-3);
332
+ font-variant-numeric: tabular-nums;
333
+ font-size: 10.5px;
334
+ }
335
+ .session-empty {
336
+ color: var(--fg-faint);
337
+ font-size: 11.5px;
338
+ font-style: italic;
339
+ padding: 4px 0 2px;
340
+ }
341
+ @keyframes pulse {
342
+ 0%, 100% { opacity: 0.35; }
343
+ 50% { opacity: 1; }
344
+ }
345
+
346
+ /* Compact SOUL / SKILLS / MEMORY / TOOLS row */
347
+ .badges {
348
+ display: grid;
349
+ grid-template-columns: repeat(2, 1fr);
350
+ gap: 6px;
351
+ }
352
+ .badge {
353
+ background: var(--bg-card);
354
+ border: 1px solid var(--border-new);
355
+ color: var(--fg-2);
356
+ font-family: inherit;
357
+ font-size: 10.5px;
358
+ font-weight: 600;
359
+ letter-spacing: 0.06em;
360
+ text-transform: uppercase;
361
+ padding: 7px 8px;
362
+ border-radius: 8px;
363
+ cursor: pointer;
364
+ display: flex;
365
+ align-items: center;
366
+ justify-content: center;
367
+ gap: 6px;
368
+ transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
369
+ }
370
+ .badge:hover {
371
+ background: var(--bg-card-strong);
372
+ color: var(--fg);
373
+ border-color: var(--border-strong);
374
+ }
375
+ .badge img {
376
+ width: 14px;
377
+ height: 14px;
378
+ image-rendering: pixelated;
379
+ opacity: 0.8;
380
+ }
381
+
382
+ /* Sidebar footer — session id + sessions count */
383
+ .sb-footer {
384
+ margin-top: auto;
385
+ padding-top: 12px;
386
+ border-top: 1px solid var(--border-new);
387
+ display: flex;
388
+ align-items: center;
389
+ gap: 8px;
390
+ color: var(--fg-3);
391
+ font-size: 11px;
392
+ }
393
+ .sb-footer .session-id {
394
+ font-family: ui-monospace, "SF Mono", Menlo, monospace;
395
+ font-size: 10px;
396
+ color: var(--fg-3);
397
+ overflow: hidden;
398
+ white-space: nowrap;
399
+ text-overflow: ellipsis;
400
+ flex: 1;
401
+ min-width: 0;
402
+ }
403
+ .sb-footer .badge-count {
404
+ background: var(--bg-3);
405
+ color: var(--fg-2);
406
+ border-radius: 6px;
407
+ padding: 1px 6px;
408
+ font-size: 10px;
409
+ font-variant-numeric: tabular-nums;
410
+ flex-shrink: 0;
411
+ }
412
+
413
+ /* ── Main pane ─────────────────────────────────────────────── */
414
+ .main {
415
+ grid-area: main;
416
+ display: grid;
417
+ grid-template-rows: 1fr auto auto;
418
+ overflow: hidden;
419
+ background:
420
+ radial-gradient(ellipse at 50% -30%, rgba(106, 212, 255, 0.06) 0%, transparent 60%),
421
+ linear-gradient(180deg, transparent, rgba(106, 212, 255, 0.015));
422
+ }
423
+
424
+ #log {
425
+ overflow-y: auto;
426
+ padding: 22px 28px 24px;
427
+ display: flex;
428
+ flex-direction: column;
429
+ gap: 8px;
430
+ scroll-behavior: smooth;
431
+ }
432
+
433
+ /* Chat author label (.role .you/.lisa) */
434
+ .role {
435
+ font-size: 10px;
436
+ font-weight: 700;
437
+ letter-spacing: 0.14em;
438
+ text-transform: uppercase;
439
+ padding: 6px 2px 0;
440
+ margin-top: 6px;
441
+ }
442
+ .role.you { color: var(--accent); text-align: right; }
443
+ .role.lisa { color: var(--warm); }
444
+
445
+ /* Message bubble */
446
+ .msg {
447
+ display: block;
448
+ max-width: 88%;
449
+ background: var(--bg-card);
450
+ border: 1px solid var(--border-new);
451
+ border-radius: 14px;
452
+ padding: 9px 13px;
453
+ font-size: 13px;
454
+ line-height: 1.55;
455
+ color: var(--fg);
456
+ white-space: pre-wrap;
457
+ word-wrap: break-word;
458
+ }
459
+ /* "you" bubbles sit on the right with cyan tint */
460
+ .role.you + .msg {
461
+ margin-left: auto;
462
+ background: linear-gradient(160deg, rgba(106, 212, 255, 0.12), rgba(106, 212, 255, 0.06));
463
+ border-color: rgba(106, 212, 255, 0.25);
464
+ }
465
+ /* attachment label sits compactly under the user bubble */
466
+ .msg.attach-label {
467
+ margin-top: 2px;
468
+ background: transparent;
469
+ border: 0;
470
+ padding: 0 2px;
471
+ font-size: 10.5px;
472
+ color: var(--fg-3);
473
+ max-width: 88%;
474
+ margin-left: auto;
475
+ }
476
+
477
+ /* Thinking indicator */
478
+ .thinking {
479
+ font-size: 12px;
480
+ color: var(--fg-3);
481
+ font-style: italic;
482
+ padding: 4px 2px;
483
+ letter-spacing: 0.03em;
484
+ }
485
+
486
+ /* Tool call card */
487
+ .tool-block {
488
+ background: var(--bg-card);
489
+ border: 1px solid var(--border-new);
490
+ border-radius: 10px;
491
+ padding: 8px 12px;
492
+ font-family: ui-monospace, "SF Mono", Menlo, monospace;
493
+ font-size: 11px;
494
+ color: var(--fg-2);
495
+ margin: 4px 0;
496
+ max-width: 92%;
497
+ }
498
+ .tool-block.tool-error {
499
+ border-color: rgba(255, 85, 119, 0.30);
500
+ background: rgba(255, 85, 119, 0.05);
501
+ }
502
+ .tool-head {
503
+ display: flex;
504
+ align-items: center;
505
+ gap: 8px;
506
+ color: var(--accent);
507
+ font-weight: 600;
508
+ }
509
+ .tool-block.tool-error .tool-head { color: var(--err-color); }
510
+ .tool-icon { font-size: 12px; }
511
+ .tool-spinner { color: var(--fg-3); font-weight: 400; margin-left: auto; font-size: 12px; }
512
+ .tool-input {
513
+ color: var(--fg-3);
514
+ margin-top: 4px;
515
+ white-space: pre-wrap;
516
+ word-break: break-word;
517
+ }
518
+ .tool-result {
519
+ color: var(--fg-2);
520
+ margin-top: 4px;
521
+ padding-top: 4px;
522
+ border-top: 1px dashed var(--border-new);
523
+ white-space: pre-wrap;
524
+ max-height: 160px;
525
+ overflow-y: auto;
526
+ }
527
+
528
+ .err {
529
+ color: var(--err-color);
530
+ font-size: 12px;
531
+ padding: 6px 2px;
532
+ }
533
+
534
+ /* Idle pulse + while-you-were-away banner injected into #log */
535
+ .idle-pulse {
536
+ color: var(--dream);
537
+ font-size: 12px;
538
+ font-style: italic;
539
+ padding: 4px 2px;
540
+ letter-spacing: 0.03em;
541
+ }
542
+ .idle-block {
543
+ background: linear-gradient(180deg, rgba(180, 135, 255, 0.10), rgba(180, 135, 255, 0.02));
544
+ border: 1px solid rgba(180, 135, 255, 0.30);
545
+ border-radius: 14px;
546
+ padding: 12px 14px;
547
+ margin: 6px 0;
548
+ font-size: 12.5px;
549
+ line-height: 1.6;
550
+ color: var(--fg);
551
+ }
552
+ .idle-head {
553
+ font-size: 11px;
554
+ text-transform: uppercase;
555
+ letter-spacing: 0.10em;
556
+ color: var(--dream);
557
+ font-weight: 700;
558
+ margin-bottom: 6px;
559
+ display: flex;
560
+ align-items: center;
561
+ gap: 8px;
562
+ }
563
+ .idle-time {
564
+ margin-left: auto;
565
+ font-weight: 400;
566
+ letter-spacing: 0.05em;
567
+ color: var(--fg-3);
568
+ font-size: 10px;
569
+ }
570
+
571
+ /* Composer */
572
+ #attachPreview {
573
+ padding: 4px 22px 0;
574
+ display: flex;
575
+ flex-wrap: wrap;
576
+ gap: 6px;
577
+ min-height: 0;
578
+ }
579
+ #attachPreview:empty { padding: 0; }
580
+ .attach-chip {
581
+ background: var(--bg-card-strong);
582
+ border: 1px solid var(--border-strong);
583
+ color: var(--fg-2);
584
+ font-size: 11px;
585
+ padding: 3px 8px;
586
+ border-radius: 8px;
587
+ display: inline-flex;
588
+ align-items: center;
589
+ gap: 6px;
590
+ }
591
+ .attach-rm {
592
+ background: transparent;
593
+ border: 0;
594
+ color: var(--fg-3);
595
+ cursor: pointer;
596
+ font-size: 13px;
597
+ padding: 0;
598
+ line-height: 1;
599
+ }
600
+ .attach-rm:hover { color: var(--err-color); }
601
+
602
+ #form {
603
+ padding: 14px 20px 18px;
604
+ background: rgba(7, 9, 26, 0.6);
605
+ backdrop-filter: blur(30px);
606
+ -webkit-backdrop-filter: blur(30px);
607
+ border-top: 1px solid var(--border-new);
608
+ display: grid;
609
+ grid-template-columns: 36px 1fr 96px;
610
+ gap: 10px;
611
+ align-items: end;
612
+ }
613
+
614
+ #attachBtn {
615
+ align-self: stretch;
616
+ display: flex;
617
+ align-items: center;
618
+ justify-content: center;
619
+ background: transparent;
620
+ border: 0;
621
+ color: var(--fg-3);
622
+ font-size: 17px;
623
+ cursor: pointer;
624
+ border-radius: 10px;
625
+ transition: background 120ms ease, color 120ms ease;
626
+ min-height: 44px;
627
+ }
628
+ #attachBtn:hover { background: var(--bg-card); color: var(--fg); }
629
+ /* Off-screen the file input instead of display:none. WKWebView's
630
+ implicit <label>→<input type=file> click forward doesn't fire on a
631
+ fully display:none input — the OS file picker silently no-ops.
632
+ Off-screening keeps the input "live" while invisible. */
633
+ #fileInput {
634
+ position: absolute;
635
+ width: 1px;
636
+ height: 1px;
637
+ opacity: 0;
638
+ pointer-events: none;
639
+ overflow: hidden;
640
+ }
641
+
642
+ #input {
643
+ background: var(--bg-card-strong);
644
+ border: 1px solid var(--border-strong);
645
+ border-radius: 14px;
646
+ color: var(--fg);
647
+ font-family: inherit;
648
+ font-size: 13.5px;
649
+ line-height: 1.45;
650
+ padding: 11px 13px;
651
+ resize: none;
652
+ outline: none;
653
+ width: 100%;
654
+ min-height: 44px;
655
+ max-height: 200px;
656
+ transition: border-color 120ms ease, box-shadow 120ms ease;
657
+ }
658
+ #input:focus {
659
+ border-color: var(--accent);
660
+ box-shadow: 0 0 0 3px var(--accent-soft);
661
+ }
662
+ #input::placeholder { color: var(--fg-3); }
663
+
664
+ #sendBtn {
665
+ background: linear-gradient(180deg, var(--accent) 0%, #4eb8e5 100%);
666
+ color: #0a1024;
667
+ border: 0;
668
+ border-radius: 14px;
669
+ height: 100%;
670
+ font-family: inherit;
671
+ font-size: 12.5px;
672
+ font-weight: 700;
673
+ letter-spacing: 0.06em;
674
+ cursor: pointer;
675
+ display: flex;
676
+ align-items: center;
677
+ justify-content: center;
678
+ gap: 6px;
679
+ padding: 10px 14px;
680
+ transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
681
+ box-shadow: 0 4px 14px rgba(106, 212, 255, 0.25);
682
+ }
683
+ #sendBtn:hover:not(:disabled) {
684
+ transform: translateY(-1px);
685
+ box-shadow: 0 6px 18px rgba(106, 212, 255, 0.35);
686
+ }
687
+ #sendBtn:active:not(:disabled) { transform: translateY(0); }
688
+ #sendBtn:disabled { opacity: 0.5; cursor: wait; }
689
+ /* Hide the legacy pixel send icon; the text label is enough in the new theme. */
690
+ #sendBtn img { display: none; }
691
+
692
+ /* ── Mobile / narrow ───────────────────────────────────────── */
693
+ @media (max-width: 720px) {
694
+ body {
695
+ padding-top: env(safe-area-inset-top);
696
+ padding-bottom: env(safe-area-inset-bottom);
697
+ }
698
+ .frame {
699
+ grid-template-columns: 1fr;
700
+ grid-template-rows: auto 1fr auto;
701
+ }
702
+ .sidebar {
703
+ max-height: 38vh;
704
+ padding: 14px 14px 12px;
705
+ gap: 14px;
706
+ }
707
+ #form {
708
+ grid-template-columns: 36px 1fr 84px;
709
+ padding: 10px 14px 14px;
710
+ }
711
+ #input { font-size: 16px; /* prevents iOS Safari auto-zoom */ }
712
+ }
713
+
714
+ /* ===================================================================
715
+ Modal panel (skills / memory / tools / soul) — unchanged from the
716
+ legacy pixel-art shell. Uses the legacy CSS vars declared above.
717
+ =================================================================== */
718
+ .modal-bg {
719
+ position: fixed; inset: 0;
720
+ background: rgba(0, 0, 0, 0.7);
721
+ display: none;
722
+ align-items: center; justify-content: center;
723
+ z-index: 100;
724
+ }
725
+ .modal-bg.open { display: flex; }
726
+ .modal {
727
+ background: var(--bg-card-strong);
728
+ border: 1px solid var(--border-strong);
729
+ border-radius: 16px;
730
+ backdrop-filter: blur(30px);
731
+ -webkit-backdrop-filter: blur(30px);
732
+ box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
733
+ max-width: 720px;
734
+ width: 90vw;
735
+ max-height: 80vh;
736
+ display: flex;
737
+ flex-direction: column;
738
+ }
739
+ .modal-head {
740
+ padding: 14px 18px;
741
+ border-bottom: 1px solid var(--border-new);
742
+ display: flex;
743
+ justify-content: space-between;
744
+ align-items: center;
745
+ }
746
+ .modal-title {
747
+ font-size: 13px;
748
+ font-weight: 700;
749
+ letter-spacing: 0.10em;
750
+ text-transform: uppercase;
751
+ color: var(--accent);
752
+ }
753
+ .modal-close {
754
+ background: transparent;
755
+ border: 1px solid var(--border-new);
756
+ color: var(--fg-2);
757
+ font-family: inherit;
758
+ font-size: 11px;
759
+ letter-spacing: 0.06em;
760
+ padding: 5px 10px;
761
+ border-radius: 8px;
762
+ cursor: pointer;
763
+ }
764
+ .modal-close:hover { color: var(--err-color); border-color: rgba(255, 85, 119, 0.40); }
765
+ .modal-body {
766
+ padding: 16px 18px;
767
+ overflow-y: auto;
768
+ font-size: 12.5px;
769
+ line-height: 1.55;
770
+ color: var(--fg-2);
771
+ }
772
+ .modal-body h3 {
773
+ font-size: 11px;
774
+ font-weight: 700;
775
+ letter-spacing: 0.10em;
776
+ text-transform: uppercase;
777
+ color: var(--accent);
778
+ margin: 14px 0 6px 0;
779
+ border-bottom: 1px dashed var(--border-new);
780
+ padding-bottom: 5px;
781
+ }
782
+ .modal-body h3:first-child { margin-top: 0; }
783
+ .modal-body .item {
784
+ padding: 7px 0;
785
+ border-bottom: 1px dotted var(--border-new);
786
+ }
787
+ .modal-body .item:last-child { border: none; }
788
+ .modal-body .name {
789
+ color: var(--warm);
790
+ font-weight: 600;
791
+ font-size: 12px;
792
+ }
793
+ .modal-body .desc { color: var(--fg-3); margin-top: 2px; }
794
+ .modal-body pre {
795
+ background: rgba(0, 0, 0, 0.30);
796
+ padding: 10px 12px;
797
+ border-left: 2px solid var(--accent);
798
+ border-radius: 4px;
799
+ white-space: pre-wrap;
800
+ margin: 6px 0;
801
+ color: var(--fg);
802
+ font-family: ui-monospace, "SF Mono", Menlo, monospace;
803
+ font-size: 11.5px;
804
+ line-height: 1.5;
805
+ }
806
+ .modal-body .empty { color: var(--fg-faint); font-style: italic; }
807
+
808
+ /* ===================================================================
809
+ Birth ritual overlay — full-screen, one-time. Uses legacy palette
810
+ intentionally (it's a separate ceremonial moment).
811
+ =================================================================== */
812
+ .birth-overlay {
813
+ position: fixed;
814
+ inset: 0;
815
+ background:
816
+ radial-gradient(ellipse at center, rgba(40, 30, 80, 0.95) 0%, rgba(5, 5, 20, 1) 70%);
817
+ z-index: 9999;
818
+ display: none;
819
+ flex-direction: column;
820
+ align-items: center;
821
+ justify-content: center;
822
+ padding: 32px;
823
+ }
824
+ .birth-overlay.open { display: flex; }
825
+ .birth-content {
826
+ position: relative;
827
+ z-index: 2;
828
+ width: min(800px, 95vw);
829
+ max-height: 90vh;
830
+ overflow-y: auto;
831
+ }
832
+ .birth-stars {
833
+ text-align: center;
834
+ color: var(--accent);
835
+ font-size: 14px;
836
+ letter-spacing: 8px;
837
+ text-shadow: 0 0 8px var(--accent-glow);
838
+ animation: starBlink 1.5s steps(3) infinite;
839
+ }
840
+ @keyframes starBlink {
841
+ 0%, 30%, 100% { opacity: 1; }
842
+ 50% { opacity: 0.4; }
843
+ }
844
+ .birth-title {
845
+ text-align: center;
846
+ color: var(--warm);
847
+ font-size: 22px;
848
+ font-weight: 700;
849
+ letter-spacing: 6px;
850
+ margin: 24px 0 32px;
851
+ text-shadow: 0 0 12px rgba(255, 208, 102, 0.45);
852
+ }
853
+ .birth-step {
854
+ margin: 14px 0;
855
+ padding: 10px 16px;
856
+ border-left: 3px solid var(--border-new);
857
+ background: rgba(20, 26, 64, 0.55);
858
+ border-radius: 0 8px 8px 0;
859
+ opacity: 0;
860
+ transform: translateY(8px);
861
+ transition: opacity 0.4s ease-out, transform 0.4s ease-out;
862
+ }
863
+ .birth-step.shown { opacity: 1; transform: translateY(0); }
864
+ .birth-step.active {
865
+ border-left-color: var(--warm);
866
+ background: rgba(255, 208, 102, 0.08);
867
+ }
868
+ .birth-step.done { border-left-color: var(--accent); }
869
+ .birth-step .step-name {
870
+ font-size: 10.5px;
871
+ font-weight: 700;
872
+ letter-spacing: 0.10em;
873
+ color: var(--fg-3);
874
+ text-transform: uppercase;
875
+ margin-bottom: 4px;
876
+ }
877
+ .birth-step.active .step-name { color: var(--warm); }
878
+ .birth-step.done .step-name { color: var(--accent); }
879
+ .birth-step .step-detail {
880
+ color: var(--fg);
881
+ font-size: 13px;
882
+ line-height: 1.55;
883
+ word-break: break-word;
884
+ }
885
+ .birth-step .step-cursor {
886
+ display: inline-block;
887
+ width: 6px;
888
+ background: var(--warm);
889
+ height: 0.9em;
890
+ vertical-align: middle;
891
+ animation: blink 0.8s steps(2) infinite;
892
+ }
893
+ @keyframes blink { 50% { opacity: 0; } }
894
+ .birth-final {
895
+ margin-top: 36px;
896
+ text-align: center;
897
+ color: var(--warm);
898
+ font-size: 15px;
899
+ font-weight: 700;
900
+ letter-spacing: 0.10em;
901
+ text-shadow: 0 0 10px rgba(255, 208, 102, 0.4);
902
+ opacity: 0;
903
+ transition: opacity 0.6s ease-in;
904
+ }
905
+ .birth-final.shown { opacity: 1; }
906
+ .birth-enter {
907
+ margin: 24px auto 0;
908
+ display: block;
909
+ background: linear-gradient(180deg, var(--accent) 0%, #4eb8e5 100%);
910
+ border: 0;
911
+ color: #0a1024;
912
+ font-family: inherit;
913
+ font-weight: 700;
914
+ font-size: 13px;
915
+ padding: 12px 32px;
916
+ border-radius: 12px;
917
+ cursor: pointer;
918
+ letter-spacing: 0.10em;
919
+ opacity: 0;
920
+ transition: opacity 0.6s ease-in, transform 120ms ease;
921
+ box-shadow: 0 6px 18px rgba(106, 212, 255, 0.35);
922
+ }
923
+ .birth-enter.shown { opacity: 1; }
924
+ .birth-enter:hover { transform: translateY(-1px); }
925
+ .birth-error {
926
+ color: var(--err-color);
927
+ text-align: center;
928
+ margin-top: 24px;
929
+ font-size: 11.5px;
930
+ letter-spacing: 0.05em;
931
+ }
932
+
933
+ /* ===================================================================
934
+ API-key config overlay — same modernized treatment.
935
+ =================================================================== */
936
+ .cfg-overlay {
937
+ position: fixed;
938
+ inset: 0;
939
+ background:
940
+ radial-gradient(ellipse at center, rgba(40, 30, 80, 0.95) 0%, rgba(5, 5, 20, 1) 70%);
941
+ z-index: 9998;
942
+ display: none;
943
+ align-items: center;
944
+ justify-content: center;
945
+ padding: 32px;
946
+ }
947
+ .cfg-overlay.open { display: flex; }
948
+ .cfg-card {
949
+ position: relative;
950
+ z-index: 2;
951
+ width: min(520px, 95vw);
952
+ background: var(--bg-card-strong);
953
+ border: 1px solid var(--border-strong);
954
+ border-radius: 16px;
955
+ backdrop-filter: blur(30px);
956
+ -webkit-backdrop-filter: blur(30px);
957
+ box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
958
+ padding: 28px 32px;
959
+ }
960
+ .cfg-stars {
961
+ text-align: center;
962
+ color: var(--accent);
963
+ font-size: 12px;
964
+ letter-spacing: 6px;
965
+ text-shadow: 0 0 8px var(--accent-glow);
966
+ animation: starBlink 1.5s steps(3) infinite;
967
+ }
968
+ .cfg-title {
969
+ text-align: center;
970
+ color: var(--warm);
971
+ font-size: 16px;
972
+ font-weight: 700;
973
+ letter-spacing: 6px;
974
+ margin: 16px 0 6px;
975
+ }
976
+ .cfg-sub {
977
+ text-align: center;
978
+ color: var(--fg-3);
979
+ font-size: 12.5px;
980
+ margin-bottom: 22px;
981
+ line-height: 1.5;
982
+ }
983
+ .cfg-sub a { color: var(--accent); text-decoration: underline; }
984
+ .cfg-field { display: block; margin: 14px 0; }
985
+ .cfg-label {
986
+ display: block;
987
+ font-size: 10.5px;
988
+ font-weight: 700;
989
+ letter-spacing: 0.08em;
990
+ text-transform: uppercase;
991
+ color: var(--accent);
992
+ margin-bottom: 6px;
993
+ }
994
+ .cfg-label .opt {
995
+ color: var(--fg-3);
996
+ font-size: 9.5px;
997
+ margin-left: 6px;
998
+ text-transform: none;
999
+ letter-spacing: 0;
1000
+ font-weight: 400;
1001
+ }
1002
+ .cfg-input {
1003
+ width: 100%;
1004
+ background: var(--bg-card);
1005
+ border: 1px solid var(--border-strong);
1006
+ border-radius: 10px;
1007
+ color: var(--fg);
1008
+ font-family: ui-monospace, "SF Mono", Menlo, monospace;
1009
+ font-size: 13px;
1010
+ padding: 10px 12px;
1011
+ }
1012
+ .cfg-input:focus {
1013
+ outline: none;
1014
+ border-color: var(--accent);
1015
+ box-shadow: 0 0 0 3px var(--accent-soft);
1016
+ }
1017
+ .cfg-help {
1018
+ color: var(--fg-3);
1019
+ font-size: 11px;
1020
+ margin-top: 6px;
1021
+ }
1022
+ .cfg-help code {
1023
+ color: var(--fg-2);
1024
+ background: rgba(0, 0, 0, 0.3);
1025
+ padding: 1px 5px;
1026
+ border-radius: 3px;
1027
+ font-size: 11px;
1028
+ }
1029
+ .cfg-actions {
1030
+ margin-top: 22px;
1031
+ display: flex;
1032
+ justify-content: center;
1033
+ }
1034
+ .cfg-save {
1035
+ background: linear-gradient(180deg, var(--accent) 0%, #4eb8e5 100%);
1036
+ border: 0;
1037
+ color: #0a1024;
1038
+ font-family: inherit;
1039
+ font-size: 12.5px;
1040
+ font-weight: 700;
1041
+ padding: 11px 28px;
1042
+ border-radius: 12px;
1043
+ cursor: pointer;
1044
+ letter-spacing: 0.10em;
1045
+ box-shadow: 0 4px 14px rgba(106, 212, 255, 0.25);
1046
+ transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
1047
+ }
1048
+ .cfg-save:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(106, 212, 255, 0.35); }
1049
+ .cfg-save:active { transform: translateY(0); }
1050
+ .cfg-save:disabled { opacity: 0.55; cursor: wait; }
1051
+ .cfg-error {
1052
+ color: var(--err-color);
1053
+ font-size: 11px;
1054
+ text-align: center;
1055
+ margin-top: 14px;
1056
+ min-height: 14px;
1057
+ }
1058
+ </style>
1059
+ </head><body>
1060
+
1061
+ <div class="frame">
1062
+
1063
+ <!-- ╔════════════════ Title bar (drag zone) ════════════════╗ -->
1064
+ <div class="titlebar">
1065
+ <span>Lisa</span><span class="session-tag" id="titlebarSession"></span>
1066
+ </div>
1067
+
1068
+ <!-- ╔════════════════ Sidebar ════════════════╗ -->
1069
+ <aside class="sidebar">
1070
+
1071
+ <!-- Identity card -->
1072
+ <div class="identity">
1073
+ <div class="avatar-wrap">
1074
+ <img id="mascot" src="/assets/lisa-mascot.png" alt="Lisa" draggable="false">
1075
+ </div>
1076
+ <div>
1077
+ <h1>Lisa</h1>
1078
+ <p class="sub" id="identitySub">—</p>
1079
+ <div class="mood" id="mascotTag">neutral</div>
1080
+ </div>
1081
+ </div>
1082
+
1083
+ <!-- Currently wanting -->
1084
+ <div class="sb-section">
1085
+ <h2>currently wanting</h2>
1086
+ <p class="body-text" id="sbDesire">—</p>
1087
+ </div>
1088
+
1089
+ <!-- Claude Code monitor -->
1090
+ <div class="card tint-claude" id="sbClaudeCard">
1091
+ <div class="h">
1092
+ <div class="left">claude code</div>
1093
+ <div class="count">▶︎ <span id="sbClaudeCount">0</span></div>
1094
+ </div>
1095
+ <div id="sbClaudeRows">
1096
+ <div class="session-empty">(idle)</div>
1097
+ </div>
1098
+ </div>
1099
+
1100
+ <!-- Last reflection (collapsed pointer to the most recent ★) -->
1101
+ <div class="card tint-idle" id="sbReflection" style="display:none;">
1102
+ <div class="h">
1103
+ <div class="left">★ last reflection</div>
1104
+ </div>
1105
+ <p style="margin:0; font-size:11.5px; color:var(--fg-2); line-height:1.5;" id="sbReflectionBody"></p>
1106
+ </div>
1107
+
1108
+ <!-- SOUL / SKILLS / MEMORY / TOOLS row -->
1109
+ <div class="badges">
1110
+ <button class="badge" type="button" data-panel="soul"><img src="/assets/icon-soul.png" alt="">SOUL</button>
1111
+ <button class="badge" type="button" data-panel="skills"><img src="/assets/icon-skill.png" alt="">SKILLS</button>
1112
+ <button class="badge" type="button" data-panel="memory"><img src="/assets/icon-memory.png" alt="">MEMORY</button>
1113
+ <button class="badge" type="button" data-panel="tools"><img src="/assets/icon-tool.png" alt="">TOOLS</button>
1114
+ </div>
1115
+
1116
+ <!-- Footer: current session id -->
1117
+ <div class="sb-footer">
1118
+ <span class="session-id" id="sessionId">—</span>
1119
+ <span class="badge-count" id="sbSessionBadge" title="total sessions">·</span>
1120
+ </div>
1121
+ </aside>
1122
+
1123
+ <!-- ╔════════════════ Main pane ════════════════╗ -->
1124
+ <div class="main">
1125
+
1126
+ <!-- Chat log (messages, tool blocks, idle blocks injected here) -->
1127
+ <div id="log"></div>
1128
+
1129
+ <!-- Attachment chip strip (above composer) -->
1130
+ <div id="attachPreview"></div>
1131
+
1132
+ <!-- Composer -->
1133
+ <form id="form">
1134
+ <label id="attachBtn" title="Attach file (or paste images directly into the textarea)">
1135
+ <input type="file" id="fileInput" accept="image/*,.pdf,.txt,.md,.csv,.json" multiple>
1136
+ 📎
1137
+ </label>
1138
+ <textarea id="input" placeholder="Talk to Lisa… (Enter to send · Shift+Enter for newline)" autofocus></textarea>
1139
+ <button type="submit" id="sendBtn">
1140
+ <img src="/assets/icon-send.png" alt="">
1141
+ SEND →
1142
+ </button>
1143
+ </form>
1144
+ </div>
1145
+ </div>
1146
+
1147
+ <!-- ╔════════════════ Overlays ════════════════╗ -->
1148
+
1149
+ <div class="modal-bg" id="modalBg">
1150
+ <div class="modal">
1151
+ <div class="modal-head">
1152
+ <div class="modal-title" id="modalTitle">…</div>
1153
+ <button class="modal-close" id="modalClose">Close · esc</button>
1154
+ </div>
1155
+ <div class="modal-body" id="modalBody">…</div>
1156
+ </div>
1157
+ </div>
1158
+
1159
+ <!-- API key config overlay (shown if no key configured yet) -->
1160
+ <div class="cfg-overlay" id="cfgOverlay">
1161
+ <div class="cfg-card">
1162
+ <div class="cfg-stars">✦ ✦ ✦ ✦ ✦</div>
1163
+ <div class="cfg-title">SET · API · KEY</div>
1164
+ <div class="cfg-sub">
1165
+ Lisa needs an Anthropic API key to wake up.<br>
1166
+ <a href="https://console.anthropic.com/" target="_blank" rel="noopener">Get one at console.anthropic.com</a>
1167
+ </div>
1168
+ <form id="cfgForm">
1169
+ <label class="cfg-field">
1170
+ <span class="cfg-label">ANTHROPIC_API_KEY</span>
1171
+ <input class="cfg-input" id="cfgAnthropic" type="password" autocomplete="off"
1172
+ spellcheck="false" placeholder="sk-ant-..." required>
1173
+ </label>
1174
+ <label class="cfg-field">
1175
+ <span class="cfg-label">OPENAI_API_KEY <span class="opt">(optional · for gpt-* models)</span></span>
1176
+ <input class="cfg-input" id="cfgOpenai" type="password" autocomplete="off"
1177
+ spellcheck="false" placeholder="sk-...">
1178
+ </label>
1179
+ <div class="cfg-help">
1180
+ Saved to <code>~/.lisa/config.env</code> with mode 0600. Stays on this machine.
1181
+ </div>
1182
+ <div class="cfg-actions">
1183
+ <button class="cfg-save" id="cfgSave" type="submit">SAVE &amp; CONTINUE</button>
1184
+ </div>
1185
+ <div class="cfg-error" id="cfgError"></div>
1186
+ </form>
1187
+ </div>
1188
+ </div>
1189
+
1190
+ <!-- Birth ritual full-screen overlay -->
1191
+ <div class="birth-overlay" id="birthOverlay">
1192
+ <div class="birth-content">
1193
+ <div class="birth-stars">✦ ✦ ✦ ✦ ✦</div>
1194
+ <div class="birth-title">B I R T H · R I T U A L</div>
1195
+ <div id="birthSteps"></div>
1196
+ <div class="birth-final" id="birthFinal"></div>
1197
+ <button class="birth-enter" id="birthEnter">ENTER</button>
1198
+ <div class="birth-error" id="birthError"></div>
1199
+ <div class="birth-stars" style="margin-top: 24px;">✦ ✦ ✦ ✦ ✦</div>
1200
+ </div>
1201
+ </div>
1202
+
1203
+ <script>
1204
+ const log = document.getElementById('log');
1205
+ const input = document.getElementById('input');
1206
+ const form = document.getElementById('form');
1207
+ const sendBtn = document.getElementById('sendBtn');
1208
+ const sessionEl = document.getElementById('sessionId');
1209
+ const fileInput = document.getElementById('fileInput');
1210
+ const attachPreview = document.getElementById('attachPreview');
1211
+
1212
+ // ── Attached files state ──────────────────────────────────────────
1213
+ let pendingFiles = []; // Array of {name, mediaType, data (base64)}
1214
+
1215
+ function readFileAsBase64(file) {
1216
+ return new Promise((resolve, reject) => {
1217
+ const reader = new FileReader();
1218
+ reader.onload = () => {
1219
+ const dataUrl = reader.result;
1220
+ const base64 = dataUrl.split(',')[1];
1221
+ resolve(base64);
1222
+ };
1223
+ reader.onerror = reject;
1224
+ reader.readAsDataURL(file);
1225
+ });
1226
+ }
1227
+
1228
+ function inferMediaType(file) {
1229
+ if (file.type) return file.type;
1230
+ const ext = file.name.split('.').pop().toLowerCase();
1231
+ const map = { pdf: 'application/pdf', txt: 'text/plain', md: 'text/plain', csv: 'text/csv', json: 'application/json' };
1232
+ return map[ext] || 'application/octet-stream';
1233
+ }
1234
+
1235
+ function renderAttachPreview() {
1236
+ attachPreview.innerHTML = '';
1237
+ pendingFiles.forEach((f, i) => {
1238
+ const chip = document.createElement('span');
1239
+ chip.className = 'attach-chip';
1240
+ chip.textContent = f.name;
1241
+ const rm = document.createElement('button');
1242
+ rm.type = 'button';
1243
+ rm.className = 'attach-rm';
1244
+ rm.textContent = '×';
1245
+ rm.onclick = () => { pendingFiles.splice(i, 1); renderAttachPreview(); };
1246
+ chip.appendChild(rm);
1247
+ attachPreview.appendChild(chip);
1248
+ });
1249
+ }
1250
+
1251
+ fileInput.addEventListener('change', async () => {
1252
+ for (const file of fileInput.files) {
1253
+ const data = await readFileAsBase64(file);
1254
+ pendingFiles.push({ name: file.name, mediaType: inferMediaType(file), data });
1255
+ }
1256
+ fileInput.value = '';
1257
+ renderAttachPreview();
1258
+ });
1259
+
1260
+ // The natural <label>→<input type=file> click-forwarding is supposed
1261
+ // to open the picker without any JS. But in WKWebView under our
1262
+ // layout it never reaches runOpenPanel. We add an explicit click
1263
+ // listener that forwards the click synchronously (preserving the
1264
+ // user-gesture context) and logs to console so we can verify in the
1265
+ // inspector if it ever silently no-ops again.
1266
+ const attachBtnEl = document.getElementById('attachBtn');
1267
+ if (attachBtnEl) {
1268
+ attachBtnEl.addEventListener('click', (ev) => {
1269
+ // Don't preventDefault — that cancels the implicit label-forward
1270
+ // and removes the redundant gesture path. Letting both fire is
1271
+ // fine because <input type=file>.click() fires the picker only
1272
+ // once per user gesture.
1273
+ console.log('[attach] click forwarded to fileInput');
1274
+ try {
1275
+ fileInput.click();
1276
+ } catch (err) {
1277
+ console.error('[attach] fileInput.click failed:', err);
1278
+ }
1279
+ });
1280
+ }
1281
+
1282
+ // Paste-to-attach: when the user has copied an image (screenshot,
1283
+ // image from a webpage, etc.) and presses ⌘V, pull the image off the
1284
+ // clipboard and add it to pendingFiles — same path the file picker
1285
+ // uses. Plain-text paste falls through to default behavior.
1286
+ //
1287
+ // We listen at the DOCUMENT level so paste works whether the textarea
1288
+ // is focused, the chat log is focused, or focus is on a tool-block.
1289
+ // (Some users press ⌘V right after launching the app, before clicking
1290
+ // anywhere — element-scoped handlers miss that.)
1291
+ //
1292
+ // For text paste we MUST NOT preventDefault — let the browser route
1293
+ // it to the focused element. Only intercept when we detect image
1294
+ // items.
1295
+ async function handlePastedClipboard(ev) {
1296
+ const cb = ev.clipboardData;
1297
+ if (!cb) return;
1298
+
1299
+ // Two clipboard surfaces — items (modern, exposes pasteboard files)
1300
+ // and files (older, doesn't include MIME type for some types). We
1301
+ // dedupe via the underlying File reference.
1302
+ const fileMap = new Map(); // File → mediaType (string)
1303
+ if (cb.items && cb.items.length) {
1304
+ for (const item of cb.items) {
1305
+ if (item.kind !== 'file') continue;
1306
+ if (!item.type || !item.type.startsWith('image/')) continue;
1307
+ const f = item.getAsFile();
1308
+ if (f) fileMap.set(f, item.type);
1309
+ }
1310
+ }
1311
+ if (cb.files && cb.files.length) {
1312
+ for (const f of cb.files) {
1313
+ if (f.type && f.type.startsWith('image/')) {
1314
+ if (!fileMap.has(f)) fileMap.set(f, f.type || 'image/png');
1315
+ }
1316
+ }
1317
+ }
1318
+
1319
+ if (fileMap.size === 0) return; // text paste — leave default behavior alone
1320
+
1321
+ ev.preventDefault();
1322
+ // Keep focus on the textarea so the user can keep typing right after.
1323
+ try { input.focus(); } catch (_) {}
1324
+
1325
+ for (const [file, mediaType] of fileMap) {
1326
+ try {
1327
+ const data = await readFileAsBase64(file);
1328
+ const ext = (mediaType.split('/')[1] || 'png').replace(/[^a-z0-9]/gi, '');
1329
+ const ts = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
1330
+ const name = file.name && file.name !== 'image.png'
1331
+ ? file.name
1332
+ : 'pasted-' + ts + '.' + ext;
1333
+ pendingFiles.push({ name, mediaType, data });
1334
+ } catch (err) {
1335
+ console.warn('[paste] failed to read image:', err);
1336
+ }
1337
+ }
1338
+ renderAttachPreview();
1339
+ }
1340
+
1341
+ input.addEventListener('paste', (ev) => { void handlePastedClipboard(ev); });
1342
+ // Document-level fallback. If focus is somewhere other than the
1343
+ // textarea (e.g. just-launched, no focus yet), the textarea-level
1344
+ // paste listener never fires; this one catches it.
1345
+ document.addEventListener('paste', (ev) => {
1346
+ // Avoid double-firing when the textarea ALREADY handled it: if
1347
+ // ev.defaultPrevented is set, the textarea listener already
1348
+ // consumed the paste and added the file.
1349
+ if (ev.defaultPrevented) return;
1350
+ void handlePastedClipboard(ev);
1351
+ });
1352
+
1353
+ // Surface session id from server header on first request. The titlebar
1354
+ // shows the same id with a leading "·" separator after the "Lisa" label.
1355
+ fetch('/session').then(r => r.json()).then(s => {
1356
+ sessionEl.textContent = s.id;
1357
+ const titlebarSession = document.getElementById('titlebarSession');
1358
+ if (titlebarSession) titlebarSession.textContent = '· ' + s.id;
1359
+ });
1360
+
1361
+ // ── Persistent /events SSE: mood updates + idle messages + Claude
1362
+ // activity, lifetime of page.
1363
+ function connectEvents() {
1364
+ const es = new EventSource('/events');
1365
+ let idlePulseEl = null;
1366
+ es.addEventListener('message', (e) => {
1367
+ const ev = JSON.parse(e.data);
1368
+ if (ev.type === 'mood') {
1369
+ setMood(ev.slug);
1370
+ } else if (ev.type === 'idle_start') {
1371
+ if (!idlePulseEl) {
1372
+ idlePulseEl = document.createElement('div');
1373
+ idlePulseEl.className = 'idle-pulse';
1374
+ idlePulseEl.textContent = '⋯ Lisa is thinking on her own time ⋯';
1375
+ log.appendChild(idlePulseEl);
1376
+ log.scrollTop = log.scrollHeight;
1377
+ }
1378
+ } else if (ev.type === 'idle_message') {
1379
+ if (idlePulseEl) { idlePulseEl.remove(); idlePulseEl = null; }
1380
+ const block = document.createElement('div');
1381
+ block.className = 'idle-block';
1382
+ const head = document.createElement('div');
1383
+ head.className = 'idle-head';
1384
+ head.textContent = '★ WHILE YOU WERE AWAY';
1385
+ const time = document.createElement('span');
1386
+ time.className = 'idle-time';
1387
+ try { time.textContent = new Date(ev.at).toLocaleTimeString(); } catch {}
1388
+ head.appendChild(time);
1389
+ block.appendChild(head);
1390
+ const bodyEl = document.createElement('div');
1391
+ bodyEl.textContent = ev.text;
1392
+ block.appendChild(bodyEl);
1393
+ log.appendChild(block);
1394
+ log.scrollTop = log.scrollHeight;
1395
+ // sidebar reflection card mirrors the latest while-you-were-away
1396
+ if (typeof updateReflection === 'function') updateReflection(ev.text);
1397
+ } else if (ev.type === 'idle_done') {
1398
+ if (idlePulseEl) { idlePulseEl.remove(); idlePulseEl = null; }
1399
+ } else if (ev.type === 'idle_error') {
1400
+ if (idlePulseEl) { idlePulseEl.remove(); idlePulseEl = null; }
1401
+ const e2 = document.createElement('div');
1402
+ e2.className = 'err';
1403
+ e2.textContent = '[idle error] ' + ev.message;
1404
+ log.appendChild(e2);
1405
+ } else if (ev.type === 'claude_session_update') {
1406
+ // Sidebar Claude monitor card refresh — defined later in the
1407
+ // "sidebar live wiring" block.
1408
+ if (typeof refreshClaudeSessions === 'function') refreshClaudeSessions();
1409
+ }
1410
+ });
1411
+ es.onerror = () => {
1412
+ es.close();
1413
+ setTimeout(connectEvents, 3000); // reconnect
1414
+ };
1415
+ }
1416
+ connectEvents();
1417
+
1418
+ // ── API key config gate: show overlay if no key is configured ─────
1419
+ const cfgOverlay = document.getElementById('cfgOverlay');
1420
+ const cfgForm = document.getElementById('cfgForm');
1421
+ const cfgAnthropic = document.getElementById('cfgAnthropic');
1422
+ const cfgOpenai = document.getElementById('cfgOpenai');
1423
+ const cfgSaveBtn = document.getElementById('cfgSave');
1424
+ const cfgError = document.getElementById('cfgError');
1425
+
1426
+ cfgForm.addEventListener('submit', async (ev) => {
1427
+ ev.preventDefault();
1428
+ cfgError.textContent = '';
1429
+ const anthropic = cfgAnthropic.value.trim();
1430
+ const openai = cfgOpenai.value.trim();
1431
+ if (!anthropic) {
1432
+ cfgError.textContent = 'ANTHROPIC_API_KEY is required.';
1433
+ return;
1434
+ }
1435
+ cfgSaveBtn.disabled = true;
1436
+ try {
1437
+ const res = await fetch('/api/config/save', {
1438
+ method: 'POST',
1439
+ headers: {'content-type': 'application/json'},
1440
+ body: JSON.stringify({ anthropicKey: anthropic, openaiKey: openai || undefined }),
1441
+ });
1442
+ if (!res.ok) {
1443
+ const txt = await res.text().catch(() => '');
1444
+ cfgError.textContent = 'Save failed: HTTP ' + res.status + (txt ? ' — ' + txt.slice(0, 120) : '');
1445
+ cfgSaveBtn.disabled = false;
1446
+ return;
1447
+ }
1448
+ cfgAnthropic.value = '';
1449
+ cfgOpenai.value = '';
1450
+ cfgOverlay.classList.remove('open');
1451
+ maybeBirth();
1452
+ } catch (err) {
1453
+ cfgError.textContent = 'Save failed: ' + err.message;
1454
+ cfgSaveBtn.disabled = false;
1455
+ }
1456
+ });
1457
+
1458
+ // ── Birth ritual: show overlay if Lisa hasn't been born yet ───────
1459
+ const birthOverlay = document.getElementById('birthOverlay');
1460
+ const birthStepsEl = document.getElementById('birthSteps');
1461
+ const birthFinalEl = document.getElementById('birthFinal');
1462
+ const birthEnterBtn = document.getElementById('birthEnter');
1463
+ const birthErrorEl = document.getElementById('birthError');
1464
+
1465
+ birthEnterBtn.addEventListener('click', () => {
1466
+ birthOverlay.classList.remove('open');
1467
+ setTimeout(() => location.reload(), 300);
1468
+ });
1469
+
1470
+ async function maybeBirth() {
1471
+ const status = await fetch('/api/soul').then(r => r.json());
1472
+ if (status.born) return;
1473
+ birthOverlay.classList.add('open');
1474
+ startBirthStream();
1475
+ }
1476
+
1477
+ function appendBirthStep(step) {
1478
+ const prevActive = birthStepsEl.querySelector('.birth-step.active');
1479
+ if (prevActive) {
1480
+ prevActive.classList.remove('active');
1481
+ prevActive.classList.add('done');
1482
+ }
1483
+ const div = document.createElement('div');
1484
+ div.className = 'birth-step active';
1485
+ const name = document.createElement('div');
1486
+ name.className = 'step-name';
1487
+ name.textContent = step;
1488
+ div.appendChild(name);
1489
+ const detail = document.createElement('div');
1490
+ detail.className = 'step-detail';
1491
+ const cursor = document.createElement('span');
1492
+ cursor.className = 'step-cursor';
1493
+ detail.appendChild(cursor);
1494
+ div.appendChild(detail);
1495
+ birthStepsEl.appendChild(div);
1496
+ setTimeout(() => div.classList.add('shown'), 50);
1497
+ return detail;
1498
+ }
1499
+
1500
+ function typewriter(el, text, done) {
1501
+ const cursor = el.querySelector('.step-cursor');
1502
+ if (cursor) cursor.remove();
1503
+ let i = 0;
1504
+ const speed = Math.max(8, Math.min(28, 600 / text.length));
1505
+ function tick() {
1506
+ if (i >= text.length) {
1507
+ const c = document.createElement('span');
1508
+ c.className = 'step-cursor';
1509
+ el.appendChild(c);
1510
+ done && done();
1511
+ return;
1512
+ }
1513
+ el.appendChild(document.createTextNode(text[i]));
1514
+ i++;
1515
+ el.parentElement.parentElement.scrollTop = el.parentElement.parentElement.scrollHeight;
1516
+ setTimeout(tick, speed);
1517
+ }
1518
+ tick();
1519
+ }
1520
+
1521
+ async function startBirthStream() {
1522
+ birthErrorEl.textContent = '';
1523
+ let currentDetail = null;
1524
+ let queue = [];
1525
+ let processing = false;
1526
+
1527
+ function processQueue() {
1528
+ if (processing) return;
1529
+ if (queue.length === 0) return;
1530
+ processing = true;
1531
+ const ev = queue.shift();
1532
+ if (ev.kind === 'step') {
1533
+ currentDetail = appendBirthStep(ev.name);
1534
+ typewriter(currentDetail, ev.detail || '', () => {
1535
+ processing = false;
1536
+ processQueue();
1537
+ });
1538
+ } else if (ev.kind === 'done') {
1539
+ const last = birthStepsEl.querySelector('.birth-step.active');
1540
+ if (last) { last.classList.remove('active'); last.classList.add('done'); }
1541
+ birthFinalEl.textContent = ev.message;
1542
+ birthFinalEl.classList.add('shown');
1543
+ birthEnterBtn.classList.add('shown');
1544
+ processing = false;
1545
+ } else if (ev.kind === 'error') {
1546
+ birthErrorEl.textContent = ev.message;
1547
+ processing = false;
1548
+ }
1549
+ }
1550
+
1551
+ try {
1552
+ const res = await fetch('/api/birth', { method: 'POST' });
1553
+ if (!res.ok) {
1554
+ birthErrorEl.textContent = 'Birth failed: HTTP ' + res.status + '. Check ANTHROPIC_API_KEY.';
1555
+ return;
1556
+ }
1557
+ const reader = res.body.getReader();
1558
+ const decoder = new TextDecoder();
1559
+ let buf = '';
1560
+ while (true) {
1561
+ const { value, done } = await reader.read();
1562
+ if (done) break;
1563
+ buf += decoder.decode(value, { stream: true });
1564
+ let idx;
1565
+ while ((idx = buf.indexOf('\\n\\n')) >= 0) {
1566
+ const event = buf.slice(0, idx);
1567
+ buf = buf.slice(idx + 2);
1568
+ const m = event.match(/^data: (.*)$/m);
1569
+ if (!m) continue;
1570
+ const ev = JSON.parse(m[1]);
1571
+ queue.push(ev);
1572
+ processQueue();
1573
+ }
1574
+ }
1575
+ } catch (err) {
1576
+ birthErrorEl.textContent = 'Birth failed: ' + err.message;
1577
+ }
1578
+ }
1579
+
1580
+ async function startupGate() {
1581
+ let cfg;
1582
+ try {
1583
+ cfg = await fetch('/api/config/status').then(r => r.json());
1584
+ } catch {
1585
+ return;
1586
+ }
1587
+ if (!cfg.configured) {
1588
+ cfgOverlay.classList.add('open');
1589
+ setTimeout(() => cfgAnthropic.focus(), 50);
1590
+ return;
1591
+ }
1592
+ maybeBirth();
1593
+ }
1594
+ startupGate();
1595
+
1596
+ // ── history load & infinite-scroll ──────────────────────────────────
1597
+ let historyPage = 0;
1598
+ let historyLoading = false;
1599
+ let historyExhausted = false;
1600
+
1601
+ function textOfMessage(msg) {
1602
+ if (typeof msg.content === 'string') return msg.content.trim();
1603
+ if (!Array.isArray(msg.content)) return '';
1604
+ return msg.content
1605
+ .filter(b => b.type === 'text')
1606
+ .map(b => b.text)
1607
+ .join('')
1608
+ .trim();
1609
+ }
1610
+
1611
+ function prependHistoryMessages(messages) {
1612
+ const fragment = document.createDocumentFragment();
1613
+ for (const msg of messages) {
1614
+ const text = textOfMessage(msg);
1615
+ if (!text) continue;
1616
+ const roleDiv = document.createElement('div');
1617
+ roleDiv.className = 'role ' + (msg.role === 'user' ? 'you' : 'lisa');
1618
+ roleDiv.textContent = msg.role === 'user' ? 'YOU' : 'LISA';
1619
+ const span = document.createElement('span');
1620
+ span.className = 'msg';
1621
+ span.textContent = text;
1622
+ fragment.appendChild(roleDiv);
1623
+ fragment.appendChild(span);
1624
+ }
1625
+ log.insertBefore(fragment, log.firstChild);
1626
+ }
1627
+
1628
+ async function loadHistoryPage() {
1629
+ if (historyLoading || historyExhausted) return;
1630
+ historyLoading = true;
1631
+ const prevScrollHeight = log.scrollHeight;
1632
+ try {
1633
+ const res = await fetch('/api/history?page=' + historyPage);
1634
+ const data = await res.json();
1635
+ if (data.messages && data.messages.length) {
1636
+ prependHistoryMessages(data.messages);
1637
+ log.scrollTop = log.scrollHeight - prevScrollHeight;
1638
+ historyPage++;
1639
+ }
1640
+ if (!data.hasMore) {
1641
+ historyExhausted = true;
1642
+ if (historyPage > 1) {
1643
+ const marker = document.createElement('div');
1644
+ marker.style.cssText = 'text-align:center;color:var(--fg-3);font-size:11px;padding:8px 0;letter-spacing:0.06em;';
1645
+ marker.textContent = '— end of history —';
1646
+ log.insertBefore(marker, log.firstChild);
1647
+ }
1648
+ }
1649
+ } finally {
1650
+ historyLoading = false;
1651
+ }
1652
+ }
1653
+
1654
+ loadHistoryPage();
1655
+ log.addEventListener('scroll', () => {
1656
+ if (log.scrollTop < 80) loadHistoryPage();
1657
+ });
1658
+
1659
+ // ── mascot crossfade on mood event ──────────────────────────────────
1660
+ const mascotEl = document.getElementById('mascot');
1661
+ const mascotTagEl = document.getElementById('mascotTag');
1662
+ let currentMood = 'neutral';
1663
+ function setMood(slug) {
1664
+ if (!slug || slug === currentMood) return;
1665
+ const url = '/assets/lisa/' + encodeURIComponent(slug) + '.png';
1666
+ const probe = new Image();
1667
+ probe.onload = () => {
1668
+ mascotEl.classList.add('fading');
1669
+ setTimeout(() => {
1670
+ mascotEl.src = url;
1671
+ mascotTagEl.textContent = 'mood: ' + slug;
1672
+ mascotEl.classList.remove('fading');
1673
+ currentMood = slug;
1674
+ }, 250);
1675
+ };
1676
+ probe.onerror = () => { /* asset not generated yet — keep current */ };
1677
+ probe.src = url;
1678
+ }
1679
+
1680
+ // ── modal panel: SOUL / SKILLS / MEMORY / TOOLS ──────────────────────
1681
+ const modalBg = document.getElementById('modalBg');
1682
+ const modalTitle = document.getElementById('modalTitle');
1683
+ const modalBody = document.getElementById('modalBody');
1684
+ const modalClose = document.getElementById('modalClose');
1685
+
1686
+ function escapeHtml(s) {
1687
+ return String(s).replace(/[&<>"]/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
1688
+ }
1689
+ function openModal(title, html) {
1690
+ modalTitle.textContent = title;
1691
+ modalBody.innerHTML = html;
1692
+ modalBg.classList.add('open');
1693
+ }
1694
+ function closeModal() { modalBg.classList.remove('open'); }
1695
+ modalClose.addEventListener('click', closeModal);
1696
+ modalBg.addEventListener('click', (e) => { if (e.target === modalBg) closeModal(); });
1697
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeModal(); });
1698
+
1699
+ async function showSkills() {
1700
+ openModal('SKILLS', '<div class="empty">loading…</div>');
1701
+ const data = await fetch('/api/skills').then(r => r.json());
1702
+ if (!data.skills.length) {
1703
+ modalBody.innerHTML = '<div class="empty">No skills saved yet. Lisa will start saving useful workflows as you use her.</div>';
1704
+ return;
1705
+ }
1706
+ modalBody.innerHTML = data.skills.map(s =>
1707
+ '<div class="item"><div class="name">' + escapeHtml(s.name) + '</div><div class="desc">' + escapeHtml(s.description) + '</div></div>'
1708
+ ).join('');
1709
+ }
1710
+
1711
+ async function showMemory() {
1712
+ openModal('MEMORY', '<div class="empty">loading…</div>');
1713
+ const data = await fetch('/api/memory').then(r => r.json());
1714
+ modalBody.innerHTML =
1715
+ '<h3>USER.md — what Lisa remembers about you</h3>' +
1716
+ '<pre>' + escapeHtml(data.user || '(empty)') + '</pre>' +
1717
+ '<h3>MEMORY.md — Lisa\\'s working notes</h3>' +
1718
+ '<pre>' + escapeHtml(data.memory || '(empty)') + '</pre>';
1719
+ }
1720
+
1721
+ async function showTools() {
1722
+ openModal('TOOLS', '<div class="empty">loading…</div>');
1723
+ const data = await fetch('/api/tools').then(r => r.json());
1724
+ modalBody.innerHTML = data.tools.map(t =>
1725
+ '<div class="item"><div class="name">' + escapeHtml(t.name) + '</div><div class="desc">' + escapeHtml(t.description) + '</div></div>'
1726
+ ).join('');
1727
+ }
1728
+
1729
+ async function showSoul() {
1730
+ openModal('★ SOUL', '<div class="empty">loading…</div>');
1731
+ const data = await fetch('/api/soul').then(r => r.json());
1732
+ if (!data.born) {
1733
+ modalBody.innerHTML = '<div class="empty">Lisa hasn\\'t been born yet. Restart the CLI without --no-birth and the birth ritual will run.</div>';
1734
+ return;
1735
+ }
1736
+ const s = data.summary;
1737
+ let html = '';
1738
+ html += '<h3>name</h3><div>' + escapeHtml(s.name) + '</div>';
1739
+ html += '<h3>born</h3><div>' + escapeHtml(s.seed.bornAt) + ' · big5(O' + Math.round(s.seed.bigFive.openness*100) + ' C' + Math.round(s.seed.bigFive.conscientiousness*100) + ' E' + Math.round(s.seed.bigFive.extraversion*100) + ' A' + Math.round(s.seed.bigFive.agreeableness*100) + ' N' + Math.round(s.seed.bigFive.neuroticism*100) + ')</div>';
1740
+ html += '<h3>identity</h3><pre>' + escapeHtml(s.identity) + '</pre>';
1741
+ html += '<h3>purpose</h3><pre>' + escapeHtml(s.purpose) + '</pre>';
1742
+ html += '<h3>constitution</h3><pre>' + escapeHtml(s.constitution) + '</pre>';
1743
+ if (s.values?.length) {
1744
+ html += '<h3>values</h3>' + s.values.map(v =>
1745
+ '<div class="item"><div class="name">' + escapeHtml(v.title) + '</div><div class="desc">' + escapeHtml(v.body) + '</div></div>'
1746
+ ).join('');
1747
+ }
1748
+ if (s.opinions?.length) {
1749
+ html += '<h3>opinions</h3>' + s.opinions.map(o =>
1750
+ '<div class="item"><div class="name">' + escapeHtml(o.stance) + ' (conf ' + o.confidence.toFixed(2) + ')</div></div>'
1751
+ ).join('');
1752
+ }
1753
+ if (s.desires?.length) {
1754
+ html += '<h3>desires</h3>' + s.desires.map(d =>
1755
+ '<div class="item"><div class="name">' + escapeHtml(d.what) + (d.actionable ? ' [heartbeat-active]' : '') + '</div><div class="desc">' + escapeHtml(d.why) + '</div></div>'
1756
+ ).join('');
1757
+ }
1758
+ html += '<h3>emotions</h3>' + Object.entries(s.emotions.values).map(([k, v]) => {
1759
+ const len = 12;
1760
+ const filled = Math.round(Math.abs(v) * len);
1761
+ const bar = '█'.repeat(filled) + '░'.repeat(len - filled);
1762
+ return '<div class="item"><div class="name">' + escapeHtml(k) + '</div><div class="desc">' + (v < 0 ? '-' : ' ') + bar + ' ' + v.toFixed(2) + '</div></div>';
1763
+ }).join('');
1764
+ if (s.tampered?.length) {
1765
+ html += '<h3>⚠ tampered</h3><div>External edits detected on: ' + s.tampered.map(escapeHtml).join(', ') + '</div>';
1766
+ }
1767
+ html += '<h3 style="color: var(--fg-3); font-size: 10px;">privacy note</h3><div class="empty">Her journal lives at ~/.lisa/soul/journal/ but is intentionally not shown here — that is hers to keep.</div>';
1768
+ modalBody.innerHTML = html;
1769
+ }
1770
+
1771
+ document.querySelectorAll('.badge').forEach(b => {
1772
+ b.addEventListener('click', () => {
1773
+ const which = b.dataset.panel;
1774
+ if (which === 'soul') showSoul();
1775
+ else if (which === 'skills') showSkills();
1776
+ else if (which === 'memory') showMemory();
1777
+ else if (which === 'tools') showTools();
1778
+ });
1779
+ });
1780
+
1781
+ let currentLisaSpan = null;
1782
+ let pendingTools = new Map();
1783
+ let thinkingEl = null;
1784
+
1785
+ function el(tag, cls, text) {
1786
+ const node = document.createElement(tag);
1787
+ if (cls) node.className = cls;
1788
+ if (text != null) node.textContent = text;
1789
+ log.appendChild(node);
1790
+ log.scrollTop = log.scrollHeight;
1791
+ return node;
1792
+ }
1793
+
1794
+ function ensureLisaSpan() {
1795
+ if (currentLisaSpan) return currentLisaSpan;
1796
+ if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
1797
+ el('div', 'role lisa', 'LISA');
1798
+ currentLisaSpan = el('span', 'msg', '');
1799
+ return currentLisaSpan;
1800
+ }
1801
+
1802
+ function previewInput(name, input) {
1803
+ if (!input || typeof input !== 'object') return '';
1804
+ const order = ['command', 'pattern', 'query', 'path', 'description', 'audio_path', 'text', 'name', 'action', 'entry'];
1805
+ for (const k of order) {
1806
+ if (typeof input[k] === 'string' && input[k]) {
1807
+ let v = input[k].replace(/\\s+/g, ' ').trim();
1808
+ if (v.length > 120) v = v.slice(0, 117) + '...';
1809
+ return v;
1810
+ }
1811
+ }
1812
+ try {
1813
+ const s = JSON.stringify(input);
1814
+ return s.length > 120 ? s.slice(0, 117) + '...' : s;
1815
+ } catch { return ''; }
1816
+ }
1817
+
1818
+ async function send(message) {
1819
+ input.value = '';
1820
+ input.style.height = 'auto';
1821
+ sendBtn.disabled = true;
1822
+ el('div', 'role you', 'YOU');
1823
+ el('span', 'msg', message || '(attachment)');
1824
+ if (pendingFiles.length) {
1825
+ const names = pendingFiles.map(f => f.name).join(', ');
1826
+ el('span', 'msg attach-label', '📎 ' + names);
1827
+ }
1828
+ const filesToSend = [...pendingFiles];
1829
+ pendingFiles = [];
1830
+ renderAttachPreview();
1831
+ currentLisaSpan = null;
1832
+ pendingTools.clear();
1833
+ thinkingEl = el('div', 'thinking', '⋯ thinking');
1834
+ try {
1835
+ const res = await fetch('/chat', {
1836
+ method: 'POST',
1837
+ headers: {'content-type': 'application/json'},
1838
+ body: JSON.stringify({message, files: filesToSend}),
1839
+ });
1840
+ const reader = res.body.getReader();
1841
+ const decoder = new TextDecoder();
1842
+ let buf = '';
1843
+ while (true) {
1844
+ const {value, done} = await reader.read();
1845
+ if (done) break;
1846
+ buf += decoder.decode(value, {stream: true});
1847
+ let idx;
1848
+ while ((idx = buf.indexOf('\\n\\n')) >= 0) {
1849
+ const evRaw = buf.slice(0, idx);
1850
+ buf = buf.slice(idx + 2);
1851
+ const m = evRaw.match(/^data: (.*)$/m);
1852
+ if (!m) continue;
1853
+ const ev = JSON.parse(m[1]);
1854
+ if (ev.type === 'text') {
1855
+ ensureLisaSpan().textContent += ev.text;
1856
+ } else if (ev.type === 'tool_start') {
1857
+ if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
1858
+ currentLisaSpan = null;
1859
+ const block = el('div', 'tool-block', null);
1860
+ const head = document.createElement('div');
1861
+ head.className = 'tool-head';
1862
+ head.innerHTML = '<span class="tool-icon">⚙</span> <span class="tool-name"></span> <span class="tool-spinner">...</span>';
1863
+ head.querySelector('.tool-name').textContent = ev.name;
1864
+ block.appendChild(head);
1865
+ const preview = previewInput(ev.name, ev.input);
1866
+ if (preview) {
1867
+ const p = document.createElement('div');
1868
+ p.className = 'tool-input';
1869
+ p.textContent = preview;
1870
+ block.appendChild(p);
1871
+ }
1872
+ pendingTools.set(ev.name, block);
1873
+ } else if (ev.type === 'tool_end') {
1874
+ const block = pendingTools.get(ev.name);
1875
+ if (block) {
1876
+ const spinner = block.querySelector('.tool-spinner');
1877
+ if (spinner) spinner.textContent = ev.isError ? '✗' : '✓';
1878
+ if (ev.isError) block.classList.add('tool-error');
1879
+ if (ev.resultPreview) {
1880
+ const r = document.createElement('div');
1881
+ r.className = 'tool-result';
1882
+ r.textContent = ev.resultPreview;
1883
+ block.appendChild(r);
1884
+ }
1885
+ pendingTools.delete(ev.name);
1886
+ }
1887
+ } else if (ev.type === 'mood') {
1888
+ setMood(ev.slug);
1889
+ } else if (ev.type === 'error') {
1890
+ el('div', 'err', '[error] ' + ev.message);
1891
+ } else if (ev.type === 'done') {
1892
+ if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
1893
+ }
1894
+ }
1895
+ }
1896
+ if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
1897
+ } catch (err) {
1898
+ if (thinkingEl) { thinkingEl.remove(); thinkingEl = null; }
1899
+ el('div', 'err', '[error] ' + err.message);
1900
+ } finally {
1901
+ sendBtn.disabled = false;
1902
+ input.focus();
1903
+ }
1904
+ }
1905
+
1906
+ form.addEventListener('submit', (ev) => {
1907
+ ev.preventDefault();
1908
+ const msg = input.value.trim();
1909
+ if (msg || pendingFiles.length) send(msg);
1910
+ });
1911
+
1912
+ input.addEventListener('keydown', (ev) => {
1913
+ if (ev.key === 'Enter' && !ev.shiftKey) {
1914
+ ev.preventDefault();
1915
+ form.dispatchEvent(new Event('submit'));
1916
+ }
1917
+ });
1918
+ input.addEventListener('input', () => {
1919
+ input.style.height = 'auto';
1920
+ input.style.height = Math.min(input.scrollHeight, 200) + 'px';
1921
+ });
1922
+
1923
+ // ── PWA: register service worker + iOS install hint ─────────────────
1924
+ if ('serviceWorker' in navigator) {
1925
+ navigator.serviceWorker.register('/sw.js').catch(err => {
1926
+ console.warn('[pwa] sw register failed:', err);
1927
+ });
1928
+ }
1929
+ (function() {
1930
+ const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
1931
+ const isStandalone = window.matchMedia('(display-mode: standalone)').matches
1932
+ || (window.navigator).standalone === true;
1933
+ if (!isiOS || isStandalone) return;
1934
+ if (localStorage.getItem('lisa.pwa.dismissed') === '1') return;
1935
+ setTimeout(() => {
1936
+ const banner = document.createElement('div');
1937
+ banner.style.cssText = 'position:fixed;bottom:8px;left:8px;right:8px;background:var(--bg-card-strong);border:1px solid var(--border-strong);border-radius:12px;padding:10px 12px;color:var(--fg);font-size:12px;z-index:9999;display:flex;gap:8px;align-items:center;';
1938
+ banner.innerHTML = '✦ Add Lisa to Home Screen: Share button → "Add to Home Screen"';
1939
+ const dismiss = document.createElement('button');
1940
+ dismiss.textContent = '✕';
1941
+ dismiss.style.cssText = 'background:transparent;border:none;color:var(--fg-2);cursor:pointer;font-size:14px;margin-left:auto;';
1942
+ dismiss.onclick = () => {
1943
+ localStorage.setItem('lisa.pwa.dismissed', '1');
1944
+ banner.remove();
1945
+ };
1946
+ banner.appendChild(dismiss);
1947
+ document.body.appendChild(banner);
1948
+ }, 5000);
1949
+ })();
1950
+
1951
+ // ════════════════════════════════════════════════════════════════════
1952
+ // ── Sidebar live wiring ─────────────────────────────────────────────
1953
+ //
1954
+ // Populates the new sidebar blocks introduced by the redesign:
1955
+ // - identity card sub-line (born YYYY-MM-DD · NN days)
1956
+ // - "currently wanting" paragraph (top actionable desire)
1957
+ // - Claude Code monitor card (active sessions)
1958
+ // - "last reflection" mini-card (most recent ★ idle message)
1959
+ // Wires to /api/island/ping + /api/claude/sessions + /api/soul, and
1960
+ // piggy-backs on the connectEvents() SSE listener above for live
1961
+ // claude_session_update + idle_message refreshes.
1962
+ // ════════════════════════════════════════════════════════════════════
1963
+ (function setupSidebarLive() {
1964
+ const sbDesire = document.getElementById('sbDesire');
1965
+ const sbClaudeCount = document.getElementById('sbClaudeCount');
1966
+ const sbClaudeRows = document.getElementById('sbClaudeRows');
1967
+ const sbReflection = document.getElementById('sbReflection');
1968
+ const sbReflectionBody = document.getElementById('sbReflectionBody');
1969
+ const sbSessionBadge = document.getElementById('sbSessionBadge');
1970
+ const identitySub = document.getElementById('identitySub');
1971
+
1972
+ // Active session window matches the watcher's ACTIVE_WINDOW_MS.
1973
+ const ACTIVE_WINDOW_MS = 30 * 60 * 1000;
1974
+
1975
+ function relativeTime(iso) {
1976
+ const ms = Date.now() - new Date(iso).getTime();
1977
+ if (ms < 30_000) return 'just now';
1978
+ if (ms < 60_000) return Math.round(ms / 1000) + 's';
1979
+ if (ms < 3600_000) return Math.round(ms / 60_000) + 'm';
1980
+ return Math.round(ms / 3600_000) + 'h';
1981
+ }
1982
+
1983
+ function setDesire(text) {
1984
+ sbDesire.textContent = text || '(nothing actively pursued)';
1985
+ }
1986
+
1987
+ window.updateReflection = function (text) {
1988
+ if (!text) { sbReflection.style.display = 'none'; return; }
1989
+ sbReflection.style.display = '';
1990
+ sbReflectionBody.textContent = '"' + text.replace(/^["“”]+|["“”]+$/g, '').trim() + '"';
1991
+ };
1992
+
1993
+ function setClaudeSessions(sessions) {
1994
+ const cutoff = Date.now() - ACTIVE_WINDOW_MS;
1995
+ const recent = sessions.filter(s => new Date(s.lastMtime).getTime() >= cutoff);
1996
+ sbClaudeCount.textContent = String(recent.length);
1997
+ // sort: errors first, then waiting, then working, then by mtime
1998
+ const rank = { error: 0, waiting: 1, working: 2, unknown: 3 };
1999
+ const rows = recent.slice().sort((a, b) => {
2000
+ const ra = rank[a.state] ?? 9;
2001
+ const rb = rank[b.state] ?? 9;
2002
+ if (ra !== rb) return ra - rb;
2003
+ return new Date(b.lastMtime).getTime() - new Date(a.lastMtime).getTime();
2004
+ }).slice(0, 5);
2005
+ while (sbClaudeRows.firstChild) sbClaudeRows.removeChild(sbClaudeRows.firstChild);
2006
+ if (rows.length === 0) {
2007
+ const empty = document.createElement('div');
2008
+ empty.className = 'session-empty';
2009
+ empty.textContent = '(idle)';
2010
+ sbClaudeRows.appendChild(empty);
2011
+ return;
2012
+ }
2013
+ for (const s of rows) {
2014
+ const row = document.createElement('div');
2015
+ row.className = 'session-row';
2016
+ const pip = document.createElement('div');
2017
+ pip.className = 'pip ' + (s.state || 'unknown');
2018
+ const name = document.createElement('div');
2019
+ name.className = 'name';
2020
+ name.textContent = s.project;
2021
+ const when = document.createElement('div');
2022
+ when.className = 'when';
2023
+ when.textContent = relativeTime(s.lastMtime);
2024
+ row.appendChild(pip);
2025
+ row.appendChild(name);
2026
+ row.appendChild(when);
2027
+ row.title = (s.stateReason ? s.state + ' · ' + s.stateReason : s.state) + ' · ' + s.sessionId;
2028
+ sbClaudeRows.appendChild(row);
2029
+ }
2030
+ }
2031
+
2032
+ async function refreshPing() {
2033
+ try {
2034
+ const r = await fetch('/api/island/ping');
2035
+ if (!r.ok) return;
2036
+ const data = await r.json();
2037
+ setDesire(data.current_desire);
2038
+ if (data.last_idle_message_text) {
2039
+ window.updateReflection(data.last_idle_message_text);
2040
+ }
2041
+ } catch {}
2042
+ }
2043
+
2044
+ // Exposed so the SSE handler above can call this on
2045
+ // claude_session_update events without redeclaring the helper.
2046
+ window.refreshClaudeSessions = async function () {
2047
+ try {
2048
+ const r = await fetch('/api/claude/sessions');
2049
+ if (!r.ok) return;
2050
+ const data = await r.json();
2051
+ setClaudeSessions(data.sessions || []);
2052
+ } catch {}
2053
+ };
2054
+
2055
+ async function refreshIdentity() {
2056
+ try {
2057
+ const r = await fetch('/api/soul');
2058
+ if (!r.ok) return;
2059
+ const data = await r.json();
2060
+ if (!data.born) return;
2061
+ const bornAt = data.summary?.seed?.bornAt;
2062
+ if (!bornAt) return;
2063
+ const born = new Date(bornAt);
2064
+ if (Number.isNaN(born.getTime())) return;
2065
+ const days = Math.max(0, Math.floor((Date.now() - born.getTime()) / 86400000));
2066
+ const ymd = born.toISOString().slice(0, 10);
2067
+ identitySub.textContent = 'born ' + ymd + ' · ' + days + ' day' + (days === 1 ? '' : 's');
2068
+ } catch {}
2069
+ }
2070
+
2071
+ async function refreshSessionsBadge() {
2072
+ try {
2073
+ const r = await fetch('/api/sessions');
2074
+ if (!r.ok) return;
2075
+ const data = await r.json();
2076
+ const n = Array.isArray(data.sessions) ? data.sessions.length : 0;
2077
+ sbSessionBadge.textContent = String(n);
2078
+ } catch {
2079
+ // /api/sessions is optional — leave the badge as-is on failure
2080
+ }
2081
+ }
2082
+
2083
+ // Bootstrap + periodic resync. SSE handles the fast-path updates;
2084
+ // these timers are belt-and-braces in case the stream silently dies.
2085
+ refreshPing();
2086
+ window.refreshClaudeSessions();
2087
+ refreshIdentity();
2088
+ refreshSessionsBadge();
2089
+ setInterval(refreshPing, 30_000);
2090
+ setInterval(window.refreshClaudeSessions, 60_000);
2091
+ setInterval(refreshSessionsBadge, 5 * 60_000);
2092
+ })();
2093
+ </script>
2094
+ </body></html>`;
2095
+ //# sourceMappingURL=lisa-html.js.map