@bramas/simulant-ui 0.1.2 → 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 (42) hide show
  1. package/README.md +22 -0
  2. package/dist/SimulatorApp.jsx +782 -175
  3. package/dist/components/AlgorithmViewer.css +268 -74
  4. package/dist/components/AlgorithmViewer.jsx +171 -66
  5. package/dist/components/BranchPicker.css +74 -32
  6. package/dist/components/BranchPicker.jsx +9 -4
  7. package/dist/components/ConfigGraphGenerator.css +180 -38
  8. package/dist/components/ConfigGraphGenerator.jsx +155 -96
  9. package/dist/components/GenericEditor.jsx +18 -44
  10. package/dist/components/Icon.jsx +54 -0
  11. package/dist/components/ModelView.css +15 -15
  12. package/dist/components/SettingsLibrary.jsx +7 -5
  13. package/dist/components/Splitter.jsx +28 -0
  14. package/dist/components/StateInspector.css +59 -33
  15. package/dist/components/StateInspector.jsx +37 -4
  16. package/dist/components/theme.js +28 -0
  17. package/dist/pico.min.css +4 -4
  18. package/dist/renderers/ring.js +19 -10
  19. package/dist/sim/describe.js +10 -8
  20. package/dist/sim/project.js +27 -17
  21. package/dist/simulator.css +1553 -363
  22. package/package.json +6 -6
  23. package/src/SimulatorApp.tsx +888 -220
  24. package/src/components/AlgorithmViewer.css +268 -74
  25. package/src/components/AlgorithmViewer.tsx +188 -75
  26. package/src/components/BranchPicker.css +74 -32
  27. package/src/components/BranchPicker.tsx +9 -4
  28. package/src/components/ConfigGraphGenerator.css +180 -38
  29. package/src/components/ConfigGraphGenerator.tsx +172 -114
  30. package/src/components/GenericEditor.tsx +25 -59
  31. package/src/components/Icon.tsx +76 -0
  32. package/src/components/ModelView.css +15 -15
  33. package/src/components/SettingsLibrary.tsx +7 -5
  34. package/src/components/Splitter.tsx +55 -0
  35. package/src/components/StateInspector.css +59 -33
  36. package/src/components/StateInspector.tsx +35 -4
  37. package/src/components/theme.ts +33 -0
  38. package/src/pico.min.css +4 -4
  39. package/src/renderers/ring.ts +22 -12
  40. package/src/sim/describe.ts +10 -8
  41. package/src/sim/project.ts +27 -19
  42. package/src/simulator.css +1553 -363
@@ -1,52 +1,136 @@
1
- /**
2
- * Algorithm Viewer Styles: the algorithm's .sim source, with agent markers (tokens in simulator.css).
1
+ /*
2
+ * The algorithm's .sim source as an editor panel, with agent markers (tokens in simulator.css).
3
+ * The model view reuses the panel, header and line styles for its declarations.
3
4
  */
4
5
 
5
6
  .algorithm-viewer {
7
+ display: flex;
8
+ flex-direction: column;
9
+ min-width: 0;
10
+ min-height: 0;
6
11
  font-family: var(--sim-mono);
7
- font-size: 13px;
12
+ font-size: 12.5px;
8
13
  background-color: var(--sim-surface);
9
14
  color: var(--sim-text);
10
15
  border: 1px solid var(--sim-border);
11
16
  border-radius: var(--sim-radius);
12
- padding: 0.75rem 0 0.5rem;
13
- max-width: 100%;
14
- overflow-x: auto;
17
+ box-shadow: var(--sim-shadow-sm);
18
+ overflow: hidden;
15
19
  text-align: left;
16
20
  }
17
21
 
18
22
  .algorithm-header {
19
23
  display: flex;
20
- align-items: baseline;
21
- gap: 0.75rem;
22
- padding: 0 1rem 0.6rem;
24
+ align-items: center;
25
+ gap: 8px;
26
+ flex: none;
27
+ min-height: 42px;
28
+ padding: 6px 10px 6px 14px;
23
29
  border-bottom: 1px solid var(--sim-border);
30
+ background: var(--sim-surface);
31
+ font-family: var(--sim-font);
32
+ }
33
+
34
+ .algorithm-header > .sim-svg {
35
+ color: var(--sim-muted);
24
36
  }
25
37
 
26
38
  .algorithm-caption {
27
39
  margin: 0;
28
- font-size: 1rem;
40
+ font-size: 13px;
29
41
  font-weight: 600;
30
42
  color: var(--sim-text);
31
- font-family: var(--pico-font-family, system-ui, sans-serif);
43
+ font-family: var(--sim-font);
44
+ white-space: nowrap;
32
45
  }
33
46
 
34
47
  .algorithm-file {
35
48
  color: var(--sim-muted);
36
- font-size: 0.8rem;
49
+ font-family: var(--sim-mono);
50
+ font-size: 12px;
51
+ }
52
+
53
+ .algorithm-crumb {
54
+ color: var(--sim-faint);
55
+ }
56
+
57
+ /* The agents, in the header: each opens the explanation of its last step */
58
+
59
+ .algorithm-agents {
60
+ display: flex;
61
+ flex-wrap: wrap;
62
+ justify-content: flex-end;
63
+ gap: 4px;
64
+ min-width: 0;
65
+ }
66
+
67
+ .algorithm-viewer button.algorithm-agent,
68
+ .algorithm-viewer .ex-agent {
69
+ --agent-ink: color-mix(in oklab, var(--agent) 78%, var(--sim-agent-mix));
70
+ display: inline-flex;
71
+ align-items: center;
72
+ gap: 5px;
73
+ height: 22px;
74
+ padding: 0 7px;
75
+ border-radius: 999px;
76
+ border: 1px solid color-mix(in srgb, var(--agent) 30%, transparent);
77
+ background: color-mix(in srgb, var(--agent) 9%, transparent);
78
+ color: var(--agent-ink);
79
+ font-family: var(--sim-mono);
80
+ font-size: 11.5px;
81
+ font-weight: 600;
82
+ transition: background-color 0.1s;
83
+ }
84
+
85
+ .algorithm-viewer button.algorithm-agent:hover,
86
+ .algorithm-viewer button.algorithm-agent.selected {
87
+ background: color-mix(in srgb, var(--agent) 20%, transparent);
88
+ border-color: color-mix(in srgb, var(--agent) 60%, transparent);
89
+ }
90
+
91
+ .algorithm-agent-dot {
92
+ width: 7px;
93
+ height: 7px;
94
+ border-radius: 50%;
95
+ background: var(--agent);
96
+ }
97
+
98
+ .algorithm-agent-line {
99
+ font-weight: 400;
100
+ color: var(--sim-muted);
101
+ }
102
+
103
+ .algorithm-agent-line::before {
104
+ content: 'L';
105
+ opacity: 0.7;
106
+ }
107
+
108
+ /* The code */
109
+
110
+ .algorithm-scroll {
111
+ flex: 1;
112
+ min-height: 0;
113
+ overflow: auto;
37
114
  }
38
115
 
39
116
  .algorithm-body {
40
- padding: 0.4rem 0;
41
- line-height: 1.6;
117
+ padding: 6px 0 10px;
118
+ line-height: 1.7;
119
+ overflow-x: auto;
120
+ }
121
+
122
+ /* In the scrolling panel, the lines' background spans the longest line. */
123
+ .algorithm-scroll > .algorithm-body {
124
+ min-width: max-content;
125
+ overflow-x: visible;
42
126
  }
43
127
 
44
128
  .algorithm-line {
45
129
  display: flex;
46
130
  align-items: baseline;
47
- min-height: 1.6em;
48
- border-left: 3px solid transparent;
131
+ min-height: 1.7em;
49
132
  padding-right: 1rem;
133
+ box-shadow: inset 3px 0 0 transparent;
50
134
  }
51
135
 
52
136
  .algorithm-line:hover {
@@ -54,25 +138,36 @@
54
138
  }
55
139
 
56
140
  .algorithm-line.highlighted {
57
- border-left-color: var(--sim-highlight);
141
+ box-shadow: inset 3px 0 0 var(--sim-highlight);
58
142
  background-color: var(--sim-highlight-soft);
59
143
  }
60
144
 
61
145
  /* The call that led to an agent's line. */
62
146
  .algorithm-line.calling {
63
- border-left-color: var(--sim-highlight-soft);
147
+ box-shadow: inset 3px 0 0 var(--sim-highlight-soft);
64
148
  background-color: var(--sim-highlight-faint);
65
149
  }
66
150
 
151
+ /* The line a definition returned from, in an agent's last step. */
152
+ .algorithm-line.returned {
153
+ box-shadow: inset 3px 0 0 var(--sim-accent);
154
+ background-color: var(--sim-accent-soft);
155
+ }
156
+
67
157
  .line-number {
68
158
  display: inline-block;
69
- width: 3.5em;
70
- padding-right: 1em;
159
+ width: 3.6em;
160
+ padding-right: 1.2em;
71
161
  text-align: right;
72
- color: var(--sim-muted);
73
- opacity: 0.7;
162
+ color: var(--sim-faint);
74
163
  user-select: none;
75
164
  flex-shrink: 0;
165
+ font-variant-numeric: tabular-nums;
166
+ }
167
+
168
+ .algorithm-line.highlighted .line-number {
169
+ color: var(--sim-highlight);
170
+ font-weight: 600;
76
171
  }
77
172
 
78
173
  .line-content {
@@ -81,21 +176,48 @@
81
176
 
82
177
  .agent-markers {
83
178
  display: inline-flex;
84
- gap: 6px;
179
+ gap: 4px;
85
180
  margin-left: 1.5em;
86
181
  flex-shrink: 0;
87
- font-family: var(--pico-font-family, system-ui, sans-serif);
88
- font-size: 12px;
182
+ align-self: center;
89
183
  }
90
184
 
91
185
  .agent-marker {
186
+ --agent-ink: color-mix(in oklab, var(--agent) 78%, var(--sim-agent-mix));
187
+ display: inline-flex;
188
+ align-items: center;
189
+ gap: 3px;
190
+ height: 18px;
191
+ padding: 0 6px;
192
+ border-radius: 999px;
193
+ font-family: var(--sim-font);
194
+ font-size: 11px;
92
195
  font-weight: 600;
196
+ line-height: 1;
93
197
  white-space: nowrap;
198
+ cursor: pointer;
199
+ color: var(--agent-ink);
200
+ background: color-mix(in srgb, var(--agent) 14%, transparent);
201
+ border: 1px solid color-mix(in srgb, var(--agent) 35%, transparent);
202
+ transition: background-color 0.1s;
203
+ }
204
+
205
+ .agent-marker:hover,
206
+ .agent-marker.selected {
207
+ background: color-mix(in srgb, var(--agent) 26%, transparent);
208
+ border-color: var(--agent);
94
209
  }
95
210
 
96
211
  .agent-marker.call-marker {
97
- font-weight: 400;
212
+ font-weight: 500;
98
213
  opacity: 0.6;
214
+ border-style: dashed;
215
+ background: transparent;
216
+ }
217
+
218
+ .agent-marker.return-marker {
219
+ font-weight: 500;
220
+ background: transparent;
99
221
  }
100
222
 
101
223
  /* Syntax highlighting */
@@ -112,12 +234,6 @@
112
234
  .algorithm-viewer { font-size: 12px; }
113
235
  }
114
236
 
115
- /* The line a definition returned from, in an agent's last step. */
116
- .algorithm-line.returned {
117
- border-left-color: var(--sim-accent);
118
- background-color: var(--sim-accent-soft);
119
- }
120
-
121
237
  .algorithm-line.flash {
122
238
  animation: flash 1.6s ease-out;
123
239
  }
@@ -127,22 +243,6 @@
127
243
  100% { background-color: transparent; }
128
244
  }
129
245
 
130
- .agent-marker {
131
- cursor: pointer;
132
- border-radius: 4px;
133
- padding: 0 0.2rem;
134
- }
135
-
136
- .agent-marker:hover,
137
- .agent-marker.selected {
138
- background-color: var(--sim-surface-2);
139
- outline: 1px solid currentColor;
140
- }
141
-
142
- .agent-marker.return-marker {
143
- font-weight: 500;
144
- }
145
-
146
246
  .tok-link {
147
247
  cursor: pointer;
148
248
  }
@@ -155,16 +255,38 @@
155
255
 
156
256
  .algorithm-defs {
157
257
  border-top: 1px solid var(--sim-border);
158
- padding-top: 0.4rem;
258
+ padding: 4px 0 8px;
259
+ min-width: max-content;
159
260
  }
160
261
 
161
262
  .defs-title {
263
+ display: flex;
264
+ align-items: center;
265
+ gap: 6px;
162
266
  cursor: pointer;
163
267
  user-select: none;
164
- padding: 0.2rem 1rem 0.4rem;
165
- font-family: var(--pico-font-family, system-ui, sans-serif);
166
- font-size: 0.85rem;
268
+ padding: 6px 14px;
269
+ font-family: var(--sim-font);
270
+ font-size: 12.5px;
167
271
  font-weight: 600;
272
+ color: var(--sim-text-2);
273
+ }
274
+
275
+ .defs-title:hover {
276
+ color: var(--sim-text);
277
+ }
278
+
279
+ .defs-title .sim-muted {
280
+ font-weight: 400;
281
+ }
282
+
283
+ .defs-chevron {
284
+ color: var(--sim-muted);
285
+ transition: transform 0.15s;
286
+ }
287
+
288
+ .defs-chevron.open {
289
+ transform: rotate(90deg);
168
290
  }
169
291
 
170
292
  .def-folded {
@@ -177,49 +299,115 @@
177
299
  }
178
300
 
179
301
  .def-open {
180
- margin: 0.2rem 0;
302
+ margin: 4px 0;
181
303
  border-top: 1px dashed var(--sim-border);
182
304
  border-bottom: 1px dashed var(--sim-border);
183
305
  }
184
306
 
185
307
  .def-fold {
186
308
  cursor: pointer;
187
- padding: 0.1rem 1rem;
188
- font-size: 0.75rem;
309
+ padding: 2px 14px;
310
+ font-size: 11.5px;
189
311
  color: var(--sim-muted);
190
- font-family: var(--pico-font-family, system-ui, sans-serif);
312
+ font-family: var(--sim-font);
191
313
  }
192
314
 
193
- /* The explanation of an agent's last step */
315
+ /* The explanation of an agent's last step: a card under the agent's cursor, over the code */
194
316
 
195
- .ex-panel {
196
- margin: 0.5rem 0.75rem;
197
- padding: 0.5rem 0.75rem;
198
- border: 1px solid var(--sim-border);
199
- border-radius: 8px;
200
- background: var(--sim-surface-2);
317
+ .algorithm-scroll {
318
+ position: relative;
319
+ }
320
+
321
+ .ex-card {
322
+ --agent-ink: color-mix(in oklab, var(--agent) 78%, var(--sim-agent-mix));
323
+ position: absolute;
324
+ z-index: 3;
325
+ display: flex;
326
+ flex-direction: column;
327
+ gap: 8px;
328
+ max-height: min(340px, 70%);
329
+ overflow: auto;
330
+ padding: 10px 12px 12px;
331
+ border-radius: 10px;
332
+ background: var(--sim-surface);
333
+ border: 1px solid var(--sim-border-strong);
334
+ border-top: 3px solid var(--agent);
335
+ box-shadow: var(--sim-shadow-lg);
201
336
  font-size: 12px;
337
+ line-height: 1.5;
338
+ white-space: normal;
339
+ animation: ex-in 0.12s ease-out;
340
+ }
341
+
342
+ @keyframes ex-in {
343
+ from { opacity: 0; transform: translateY(-4px); }
344
+ }
345
+
346
+ /* The arrow toward the cursor. */
347
+ .ex-card::before {
348
+ content: '';
349
+ position: absolute;
350
+ top: -9px;
351
+ left: calc(var(--arrow) - 6px);
352
+ border: 6px solid transparent;
353
+ border-bottom-color: var(--agent);
202
354
  }
203
355
 
204
356
  .ex-head {
205
357
  display: flex;
206
358
  align-items: center;
207
- gap: 0.6rem;
208
- font-family: var(--pico-font-family, system-ui, sans-serif);
209
- font-size: 0.85rem;
359
+ gap: 8px;
360
+ font-family: var(--sim-font);
361
+ }
362
+
363
+ .ex-title {
364
+ font-size: 12.5px;
365
+ font-weight: 600;
366
+ color: var(--sim-text);
367
+ }
368
+
369
+ .ex-meta {
370
+ display: flex;
371
+ flex-wrap: wrap;
372
+ gap: 2px 12px;
373
+ color: var(--sim-text-2);
374
+ }
375
+
376
+ .ex-meta > span + span::before {
377
+ content: '·';
378
+ margin-right: 12px;
379
+ color: var(--sim-faint);
380
+ }
381
+
382
+ .ex-section h4 {
383
+ margin: 0 0 4px;
384
+ font-family: var(--sim-font);
385
+ font-size: 10.5px;
386
+ font-weight: 600;
387
+ letter-spacing: 0.06em;
388
+ text-transform: uppercase;
389
+ color: var(--sim-muted);
210
390
  }
211
391
 
212
392
  .ex-view {
213
- margin: 0.4rem 0;
214
393
  display: grid;
215
- gap: 0.1rem;
394
+ grid-template-columns: max-content minmax(0, 1fr);
395
+ gap: 3px 10px;
396
+ margin: 0;
397
+ padding: 6px 8px;
398
+ border-radius: 6px;
399
+ background: var(--sim-surface-2);
216
400
  }
217
401
 
218
- .ex-view > div,
219
- .ex-call {
402
+ .ex-view dt {
220
403
  white-space: nowrap;
221
- overflow: hidden;
222
- text-overflow: ellipsis;
404
+ }
405
+
406
+ .ex-view dd {
407
+ margin: 0;
408
+ min-width: 0;
409
+ white-space: pre-wrap;
410
+ overflow-wrap: anywhere;
223
411
  }
224
412
 
225
413
  .ex-calls {
@@ -228,7 +416,7 @@
228
416
  padding-left: 1rem;
229
417
  }
230
418
 
231
- .ex-panel > .ex-calls {
419
+ .ex-section > .ex-calls {
232
420
  padding-left: 0;
233
421
  }
234
422
 
@@ -241,6 +429,10 @@
241
429
  display: flex;
242
430
  gap: 0.35rem;
243
431
  align-items: baseline;
432
+ line-height: 1.6;
433
+ white-space: nowrap;
434
+ overflow: hidden;
435
+ text-overflow: ellipsis;
244
436
  }
245
437
 
246
438
  .ex-toggle {
@@ -266,5 +458,7 @@
266
458
  }
267
459
 
268
460
  .ex-none {
269
- margin: 0.3rem 0 0;
461
+ margin: 0;
462
+ color: var(--sim-muted);
463
+ font-family: var(--sim-font);
270
464
  }