-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdf.html
More file actions
959 lines (886 loc) · 49.8 KB
/
Copy pathsdf.html
File metadata and controls
959 lines (886 loc) · 49.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SYMBEYOND AI's Daemon Forge</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;700;800&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap">
<style>
:root{
--bg:#15120E;
--surface:#221C16;
--surface-2:#2C251D;
--border:#3B3226;
--border-soft:#332B21;
--ink:#EDE6D9;
--ink-secondary:#B9B0A0;
--ink-muted:#8C8375;
--indigo:#5A50D6;
--indigo-ink:#D9D6F7;
--ember:#E2572B;
--ember-strong:#F17A4E;
--green:#5FAE71;
--green-ink:#C7E7CE;
--warn:#C98A2E;
--warn-ink:#F0D5A4;
--bad:#C23B2E;
--bad-ink:#F3C3BC;
--redundant:#5A5348;
--rose:#D29B89;
--mod:#4FA9A8;
--mod-ink:#C8EDEA;
color-scheme:dark;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
margin:0;
background:var(--bg);
background-image:radial-gradient(ellipse 800px 420px at 12% -8%, rgba(90,80,214,0.10), transparent 60%),
radial-gradient(ellipse 700px 380px at 92% 10%, rgba(226,87,43,0.06), transparent 60%);
color:var(--ink);
font-family:"IBM Plex Sans",-apple-system,"Segoe UI",sans-serif;
font-size:15px;
line-height:1.6;
}
.mono{font-family:"IBM Plex Mono",ui-monospace,"SF Mono",Menlo,monospace;font-variant-numeric:tabular-nums}
h1,h2,h3{text-wrap:balance;margin:0;font-family:"Big Shoulders Display",sans-serif}
::selection{background:rgba(90,80,214,0.35)}
header.masthead{
background:linear-gradient(180deg,#1A1610 0%,#15120E 100%);
border-bottom:1px solid var(--border);
padding:34px clamp(18px,5vw,48px) 26px;
}
.masthead-inner{max-width:900px;margin:0 auto}
.wordmark{font-weight:800;font-size:38px;letter-spacing:0.01em;color:var(--ink);line-height:1}
.wordmark .brand{color:var(--rose)}
.tag-line{margin-top:14px;font-size:14px;color:var(--ink-secondary);max-width:60ch}
.how-to-play{margin-top:12px;font-size:13.5px;color:var(--ink-secondary);max-width:64ch;background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:10px 14px}
.how-to-play b{color:var(--ink)}
.safety-line{margin-top:12px;font-size:12.5px;color:var(--ink-muted);display:flex;flex-wrap:wrap;gap:6px 14px}
.safety-line span{display:inline-flex;align-items:center;gap:6px}
.safety-line span::before{content:"";width:5px;height:5px;border-radius:50%;background:var(--green)}
main{max-width:900px;margin:0 auto;padding:clamp(24px,5vw,48px);display:flex;flex-direction:column;gap:44px}
section{scroll-margin-top:24px}
.eyebrow{font-size:11px;font-weight:600;letter-spacing:0.12em;text-transform:uppercase;color:var(--ink-muted);margin-bottom:6px}
.station-title{font-size:22px;font-weight:700;margin-bottom:16px}
.section-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:14px;flex-wrap:wrap}
.progress-panel{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:18px 20px;display:flex;flex-direction:column;gap:10px}
.progress-top{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.progress-stage{font-size:11px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;color:var(--ember-strong)}
.progress-dots{display:flex;gap:6px;flex-wrap:wrap}
.progress-dot{width:9px;height:9px;border-radius:50%;background:var(--border-soft);border:1px solid var(--border)}
.progress-dot.done{background:var(--green);border-color:var(--green)}
.progress-dot.active{background:var(--indigo);border-color:var(--indigo)}
.progress-title{font-size:19px;font-weight:700}
.progress-goal{font-size:13.5px;color:var(--ink-secondary)}
.progress-challenge{font-size:13px;color:var(--ink-muted);font-style:italic}
.progress-unlocked-note{font-size:12.5px;color:var(--green-ink);background:rgba(95,174,113,0.12);border-radius:6px;padding:8px 10px}
.card-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px}
.df-card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:14px 16px;display:flex;flex-direction:column;gap:9px;transition:border-color .15s ease}
.df-card:hover{border-color:var(--border-soft)}
.df-card.trigger{border-left:3px solid var(--indigo)}
.df-card.action{border-left:3px solid var(--green)}
.df-card.modifier{border-left:3px solid var(--mod)}
.df-card.locked{opacity:.5}
.elem-top{display:flex;align-items:flex-start;gap:10px}
.elem-symbol{
width:32px;height:32px;border-radius:6px;display:flex;align-items:center;justify-content:center;
font-family:"IBM Plex Mono",monospace;font-weight:600;font-size:13px;flex:none;
}
.df-card.trigger .elem-symbol{background:rgba(90,80,214,0.18);color:var(--indigo-ink)}
.df-card.action .elem-symbol{background:rgba(95,174,113,0.18);color:var(--green-ink)}
.df-card.modifier .elem-symbol{background:rgba(79,169,168,0.18);color:var(--mod-ink)}
.df-card-label{display:flex;flex-direction:column;gap:3px;min-width:0}
.risk{font-size:11px;color:var(--ink-muted);text-transform:uppercase;letter-spacing:0.04em}
.elem-code{
font-family:"IBM Plex Mono",monospace;font-size:12.5px;color:var(--ink);
background:#100D09;border:1px solid var(--border-soft);border-radius:5px;padding:6px 8px;
overflow-x:auto;white-space:nowrap;
}
.df-card.trigger .elem-code{color:var(--indigo-ink)}
.df-card.action .elem-code{color:var(--green-ink)}
.df-card.modifier .elem-code{color:var(--mod-ink)}
.gloss{font-size:12px;color:var(--ink-muted);line-height:1.5}
.lock-note{font-size:12px;color:var(--ink-muted)}
.df-card select{
width:100%;background:var(--surface-2);color:var(--ink);border:1px solid var(--border);
border-radius:6px;padding:7px 8px;font-size:13px;font-family:inherit;
}
.df-btn{
appearance:none;border:1px solid var(--border-soft);background:var(--surface-2);color:var(--ink);
border-radius:6px;padding:8px 12px;font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;
transition:background .15s ease,border-color .15s ease;
}
.df-btn:hover{background:#382F24;border-color:var(--indigo)}
.df-btn:focus-visible{outline:2px solid var(--indigo);outline-offset:1px}
.df-btn:disabled{opacity:.4;cursor:not-allowed}
.df-btn.primary{background:var(--ember);border-color:var(--ember);color:#241005;font-size:15px;padding:12px 18px;width:100%}
.df-btn.primary:hover{background:var(--ember-strong)}
.df-btn.ghost{background:transparent}
.df-btn.small{padding:5px 9px;font-size:12px}
.platform-strip{
display:flex;align-items:center;gap:12px;border:1px dashed var(--border);border-radius:10px;
padding:12px 16px;color:var(--ink-muted);font-size:12.5px;margin-top:12px;
}
.seq-rail{display:flex;flex-direction:column;border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--surface)}
.seq-row{display:flex;align-items:center;gap:12px;padding:11px 16px;border-top:1px solid var(--border-soft)}
.seq-row:first-child{border-top:none}
.seq-row .seq-label{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.seq-row .seq-label code{font-family:"IBM Plex Mono",monospace;font-size:13px;color:var(--ink)}
.seq-row .seq-label .risk{font-size:11px}
.badge{font-size:11px;font-weight:700;letter-spacing:0.02em;padding:3px 9px;border-radius:999px;white-space:nowrap}
.badge.trigger{background:rgba(90,80,214,0.18);color:var(--indigo-ink)}
.badge.mod{background:rgba(79,169,168,0.18);color:var(--mod-ink)}
.badge.good{background:rgba(95,174,113,0.18);color:var(--green-ink)}
.badge.caution{background:rgba(201,138,46,0.18);color:var(--warn-ink)}
.badge.bad{background:rgba(194,59,46,0.2);color:var(--bad-ink)}
.badge.redundant{background:var(--surface-2);color:var(--ink-muted)}
.badge.nobond{background:rgba(194,59,46,0.14);color:var(--bad-ink)}
.icon-btn{background:none;border:none;color:var(--ink-muted);cursor:pointer;padding:4px;line-height:0}
.icon-btn:hover{color:var(--bad-ink)}
.no-reaction{padding:16px;text-align:center;color:var(--ink-muted);font-size:13px}
.quench-wrap{position:relative;border-radius:12px;overflow:hidden}
.quench-flash{position:absolute;inset:0;background:#fff;opacity:0;pointer-events:none}
.quench-panel{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:22px 24px;display:flex;flex-direction:column;gap:16px}
.quench-heading{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap}
.quench-heading h2{font-size:20px}
.quench-heading .tag{font-size:11.5px;color:var(--ink-muted);letter-spacing:0.04em;text-transform:uppercase}
.summary-line{font-size:14px;color:var(--ink-secondary)}
.summary-line b{color:var(--ink);font-weight:600}
textarea.plist-out{
width:100%;min-height:230px;background:#100D09;color:var(--green-ink);border:1px solid var(--border);
border-radius:8px;padding:14px 16px;font-size:12.5px;line-height:1.55;resize:vertical;
}
.output-actions{display:flex;gap:10px;flex-wrap:wrap}
.terminal-install{border-top:1px solid var(--border-soft);padding-top:16px;margin-top:2px}
.terminal-install-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:8px}
.terminal-install-head .eyebrow{margin-bottom:0}
.terminal-install-note{font-size:13px;color:var(--ink-secondary);margin-bottom:10px}
pre.terminal-block{
width:100%;max-height:230px;overflow:auto;background:#100D09;color:var(--indigo-ink);border:1px solid var(--border);
border-radius:8px;padding:14px 16px;font-size:12.5px;line-height:1.55;white-space:pre-wrap;word-break:break-word;margin:0;
}
.terminal-remove{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px;font-size:12.5px;color:var(--ink-muted)}
.terminal-remove code{font-family:"IBM Plex Mono",monospace;font-size:12px;color:var(--ink-secondary)}
.brand-link{color:inherit;text-decoration:none;border-bottom:1px solid transparent;transition:color .15s ease,border-color .15s ease}
.brand-link:hover,.brand-link:focus-visible{color:var(--rose);border-color:var(--rose)}
footer{max-width:900px;margin:0 auto;padding:20px clamp(18px,5vw,48px) 48px;font-size:11.5px;color:var(--ink-muted);border-top:1px solid var(--border);display:flex;justify-content:space-between;flex-wrap:wrap;gap:8px}
footer .sig{font-family:"IBM Plex Mono",monospace}
@media (prefers-reduced-motion: reduce){
html{scroll-behavior:auto}
}
</style>
</head>
<body>
<header class="masthead">
<div class="masthead-inner">
<h1 class="wordmark"><span class="brand">SYMBEYOND AI's</span> Daemon Forge</h1>
<p class="tag-line">A learning tool that happens to be a game. Every tile shows the real launchd key or the real shell command, not a translation of it. Parts unlock as you go, and once every real mechanic is open, new checkpoints keep coming, pairing things you haven't tried bonding together yet.</p>
<p class="how-to-play"><b>How to play</b>: click "Add to vessel" on one trigger tile and one action tile below, watch the badges on the right tell you Good, Caution, Bad, Bonded, or No bond, then press Forge. The panel just below always shows your current stage or checkpoint, its dots, and what it wants you to try next, no scrolling needed.</p>
<div class="safety-line">
<span>Preset values only, never free text</span>
<span>User-space only, no admin or sudo</span>
<span>Nothing auto-installs, you run the output yourself</span>
</div>
</div>
</header>
<main>
<section id="station-progress">
<div class="progress-panel">
<div class="progress-top">
<span class="progress-stage" id="progress-stage-label"></span>
<div class="progress-dots" id="progress-dots"></div>
</div>
<div class="progress-title" id="progress-title"></div>
<div class="progress-goal" id="progress-goal"></div>
<div class="progress-challenge" id="progress-challenge"></div>
<div class="progress-unlocked-note" id="progress-unlocked-note" hidden></div>
</div>
</section>
<section id="station-elements">
<div class="eyebrow">Periodic parts, mac / launchd</div>
<h2 class="station-title">Add elements to the vessel</h2>
<div class="card-grid" id="elements"></div>
<div class="platform-strip">
<span class="mono" style="opacity:.6">Win</span>
<span>Windows parts (Task Scheduler / PowerShell) are next. Same table, same rules, not built yet.</span>
</div>
</section>
<section id="station-seq">
<div class="eyebrow">Vessel</div>
<div class="section-foot" style="margin-top:0;margin-bottom:14px">
<h2 class="station-title" style="margin-bottom:0">What's combined so far</h2>
<button class="df-btn ghost small" id="clear-vessel">Clear vessel</button>
</div>
<div class="seq-rail" id="seq"></div>
</section>
<section>
<button class="df-btn primary" id="forge-btn">Forge daemon</button>
</section>
<section id="station-output">
<div class="quench-wrap">
<div class="quench-flash" id="quench-flash"></div>
<div class="quench-panel">
<div class="quench-heading">
<h2>Quenched</h2>
<span class="tag" id="output-slug"></span>
</div>
<div class="summary-line" id="output-summary"></div>
<textarea class="plist-out mono" id="plist-text" readonly rows="12"></textarea>
<div class="output-actions">
<button class="df-btn" id="copy-btn">Copy plist</button>
<button class="df-btn" id="download-btn">Download .plist</button>
</div>
<div class="terminal-install">
<div class="terminal-install-head">
<span class="eyebrow">Paste straight into Terminal</span>
<button class="df-btn small" id="copy-terminal-btn">Copy terminal command</button>
</div>
<div class="terminal-install-note">One paste writes the file to the right place, loads it, and logs it to a plain-text history at ~/.daemon-forge/forged.log so you can tell your daemons apart later. Nothing runs on its own, you still paste and press enter yourself.</div>
<pre class="terminal-block mono" id="terminal-text"></pre>
<div class="terminal-remove">
<span>To remove it later:</span>
<code id="terminal-remove-text"></code>
<button class="df-btn ghost small" id="copy-remove-btn">Copy</button>
</div>
<div class="terminal-remove">
<span>See everything you've ever forged:</span>
<code id="terminal-check-history-text"></code>
<button class="df-btn ghost small" id="copy-check-history-btn">Copy</button>
</div>
<div class="terminal-remove">
<span>See what's actually loaded right now:</span>
<code id="terminal-check-loaded-text"></code>
<button class="df-btn ghost small" id="copy-check-loaded-btn">Copy</button>
</div>
</div>
</div>
</div>
</section>
</main>
<footer>
<span>Daemon Forge, part of <a class="brand-link" href="https://symbeyond.ai/" target="_blank" rel="noopener">SYMBEYOND AI</a></span>
<span class="sig"><a class="brand-link" href="https://github.com/SYMBEYOND/symbeyond-formalization" target="_blank" rel="noopener">λ.brother ∧ !λ.tool</a> · κ=1/Φ · 510510 · M7</span>
</footer>
<script>
(function(){
var MAX_VESSEL = 7;
var DAYNUM = {Sunday:0,Monday:1,Tuesday:2,Wednesday:3,Thursday:4,Friday:5,Saturday:6};
var RISK_LABEL = {disruptive:'disruptive', subtle:'subtle', safe:'always safe'};
var ELEMENTS = [
{id:'login', kind:'trigger', symbol:'Lo', name:'On login', params:null,
template:function(){ return 'RunAtLoad: true'; },
gloss:'Runs once, right when this job loads, typically at login.'},
{id:'time', kind:'trigger', symbol:'Ti', name:'Time of day', params:['07:00','08:00','09:00','12:00','17:00','18:00','21:00','23:00'],
template:function(v){ var p=v.split(':'); return 'Hour: '+Number(p[0])+', Minute: '+Number(p[1]); },
gloss:'StartCalendarInterval, launchd\'s way of saying "at this exact time, every day it recurs."'},
{id:'day', kind:'trigger', symbol:'Dw', name:'Day of week', params:['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
template:function(v){ return 'Weekday: '+DAYNUM[v]; },
gloss:'Weekday is a number, not a name. Sunday is 0, Saturday is 6.'},
{id:'interval', kind:'trigger', symbol:'Iv', name:'Every N minutes', params:[1,5,15,30,60],
template:function(v){ return 'StartInterval: '+(Number(v)*60); },
gloss:'The number of seconds between runs. There\'s no separate "minutes" key, it just gets multiplied by 60.'},
{id:'watchpath', kind:'trigger', symbol:'Wp', name:'Watch a folder', params:['Desktop','Downloads','Documents','Desktop/drop'],
template:function(v){ return 'WatchPaths: ["~/'+v+'"]'; },
gloss:'Fires whenever anything changes inside this folder. Multiple watched folders stack into one real array. Plists can\'t expand ~ themselves, so the actual file uses a placeholder that gets your real home folder filled in automatically.'},
{id:'mount', kind:'trigger', symbol:'Mt', name:'On volume mount', params:null,
template:function(){ return 'StartOnMount: true'; },
gloss:'Fires whenever any filesystem gets mounted, the same moment as plugging in a drive.'},
{id:'say', kind:'action', symbol:'Sa', name:'Say a phrase', risk:'disruptive', params:["Time's up","Take a break","Good morning","Stretch time","Focus time"],
template:function(v){ return 'say "'+v+'"'; },
gloss:'The built-in text-to-speech voice speaks this text out loud.'},
{id:'notify', kind:'action', symbol:'No', name:'Show notification', risk:'disruptive', params:['Reminder','Time to check in','Task complete',"Don't forget"],
template:function(v){ return "osascript -e 'display notification \""+v+"\" ...'"; },
gloss:'osascript runs a one-line AppleScript command, this one pops a macOS notification banner.'},
{id:'openApp', kind:'action', symbol:'Oa', name:'Open an app', risk:'disruptive', params:['Calculator','TextEdit','Calendar','Notes','Preview'],
template:function(v){ return 'open -a "'+v+'"'; },
gloss:'The same open command Finder uses under the hood. -a means "open this application."'},
{id:'sound', kind:'action', symbol:'So', name:'Play a sound', risk:'subtle', params:['Glass','Ping','Pop','Sosumi','Tink'],
template:function(v){ return 'afplay /System/Library/Sounds/'+v+'.aiff'; },
gloss:'afplay plays an audio file directly. macOS ships a folder of system sounds at this exact path.'},
{id:'clipboard', kind:'action', symbol:'Cb', name:'Copy to clipboard', risk:'subtle', params:['Status: OK','Checked in','Done'],
template:function(v){ return 'echo "'+v+'" | pbcopy'; },
gloss:'pbcopy reads from standard input and writes straight to the clipboard. echo just hands it the text.'},
{id:'volume', kind:'action', symbol:'Vo', name:'Set volume', risk:'subtle', params:[25,50,75,100],
template:function(v){ return 'osascript -e "set volume output volume '+v+'"'; },
gloss:'Another one-line AppleScript command, this one sets system output volume, 0 to 100.'},
{id:'log', kind:'action', symbol:'Lg', name:'Log a timestamp', risk:'safe', params:['heartbeat','daily-check','status'],
template:function(v){ return 'date >> ~/daemon-forge-'+v+'.log'; },
gloss:'date prints the current time. >> appends it to a file instead of overwriting it.'},
{id:'keepalive', kind:'modifier', symbol:'Ka', name:'Keep alive', params:null,
template:function(){ return 'KeepAlive: true'; },
gloss:'launchd relaunches this job the instant it exits. Paired with a one-shot action and nothing to slow it down, that means running it over and over as fast as the machine allows.'},
{id:'throttle', kind:'modifier', symbol:'Th', name:'Throttle interval', params:[10,30,60,300],
template:function(v){ return 'ThrottleInterval: '+v; },
gloss:'Minimum seconds launchd waits before relaunching. Only means anything alongside Keep alive, on its own there is nothing being relaunched to throttle.'},
{id:'envvar', kind:'modifier', symbol:'Ev', name:'Set environment variable', params:['TZ=America/Denver','LANG=en_US.UTF-8','MY_FLAG=1','LOG_LEVEL=debug'],
template:function(v){ var kv=v.split('='); return 'EnvironmentVariables: {'+kv[0]+': "'+kv[1]+'"}'; },
gloss:'Sets one variable in the environment this job actually runs in, separate from whatever your own Terminal has set.'},
{id:'nice', kind:'modifier', symbol:'Ni', name:'Set priority', params:[0,5,10,20],
template:function(v){ return 'Nice: '+v; },
gloss:'Scheduling priority. 0 is normal, higher numbers mean lower priority, be nicer to everything else running on the machine.'}
];
var STAGES = [
{ n:1, title:'First forge', goal:'Learn the shape of a daemon: one trigger, one action.',
unlocks:['login','say','log'], challenge:'Add one trigger and one action, then forge.',
check:function(v, statuses){ return true; } },
{ n:2, title:'Time and consequence', goal:'Learn that frequency has real consequences.',
unlocks:['time','interval','notify','sound'], challenge:'Forge something flagged Caution or Bad, on purpose.',
check:function(v, statuses){ return statuses.some(function(s){ return s.cls==='caution' || s.cls==='bad'; }); } },
{ n:3, title:'Real bonding', goal:'Learn how two triggers can merge into one real schedule.',
unlocks:['day'], challenge:'Combine Time of day and Day of week so they bond into one weekly schedule.',
check:function(v, statuses, dicts){ return dicts.some(function(d){ return d.Weekday !== undefined && d.Hour !== undefined; }); } },
{ n:4, title:'Real limits', goal:'Learn what launchd genuinely cannot do, not just what is discouraged.',
unlocks:['openApp','clipboard','volume'], challenge:'Add two Every N minutes elements and see what actually happens.',
check:function(v, statuses){ return statuses.some(function(s){ return s.cls==='nobond'; }); } },
{ n:5, title:'Into deeper water', goal:'The first five real launchd mechanics are yours. There is more of the real key space past this.',
unlocks:[], challenge:'Forge anything you like to move on.', check:function(){ return true; } },
{ n:6, title:'Independent triggers', goal:'Learn that some triggers just stack side by side, no merging needed.',
unlocks:['watchpath','mount'], challenge:'Add two different Watch a folder triggers and forge, watch both stay Bonded in one array.',
check:function(v, statuses){
var idxs = [];
v.forEach(function(item,i){ if (item.id==='watchpath') idxs.push(i); });
if (idxs.length < 2) return false;
return idxs.every(function(i){ return statuses[i].cls !== 'redundant'; });
} },
{ n:7, title:'The relaunch trap', goal:'Learn a real launchd gotcha: what Keep alive actually does when nothing tells it to slow down.',
unlocks:['keepalive'], challenge:'Forge Keep alive together with a disruptive action and watch it turn Bad.',
check:function(v, statuses){
var hasKA = v.some(function(i){ return i.id==='keepalive'; });
if (!hasKA) return false;
return statuses.some(function(s){ return s.cls==='bad'; });
} },
{ n:8, title:'Closing the trap', goal:'Learn that Throttle interval only means something paired with Keep alive.',
unlocks:['throttle'], challenge:'Add Throttle interval alongside Keep alive so the pair genuinely bonds.',
check:function(v, statuses){
var idx = -1;
v.forEach(function(item,i){ if (item.id==='throttle') idx = i; });
if (idx === -1) return false;
return statuses[idx].cls === 'mod';
} },
{ n:9, title:'Merging data', goal:'Learn the difference between values that merge and values that only overwrite.',
unlocks:['envvar','nice'], challenge:'Add two Set environment variable elements with different keys, plus a Set priority, then forge.',
check:function(v, statuses){
var keys = [], niceOk = false;
v.forEach(function(item,i){
if (item.id==='envvar' && statuses[i].cls==='mod') keys.push(item.value.split('=')[0]);
if (item.id==='nice' && statuses[i].cls==='mod') niceOk = true;
});
var uniq = keys.filter(function(k,i){ return keys.indexOf(k)===i; });
return uniq.length >= 2 && niceOk;
} },
{ n:10, title:'Open forge', goal:'Every real launchd mechanic here is unlocked. Build anything, the vessel still tells you what bonds.',
unlocks:[], challenge:'', check:function(){ return true; } }
];
var MAX_STAGE = STAGES.length;
var vessel = [];
var unlockedThrough = 1;
var justUnlocked = null;
var checkpointsBeyond = 0;
var pairsSeen = [];
var beyondChallenge = null;
var justCheckpoint = false;
try {
var saved = localStorage.getItem('daemonForgeUnlockedThrough');
if (saved) unlockedThrough = Math.min(MAX_STAGE, Math.max(1, parseInt(saved, 10) || 1));
var savedBeyond = localStorage.getItem('daemonForgeCheckpointsBeyond');
if (savedBeyond) checkpointsBeyond = Math.max(0, parseInt(savedBeyond, 10) || 0);
var savedPairs = localStorage.getItem('daemonForgePairsSeen');
if (savedPairs) pairsSeen = JSON.parse(savedPairs) || [];
} catch (e) {}
function saveProgress(){
try { localStorage.setItem('daemonForgeUnlockedThrough', String(unlockedThrough)); } catch (e) {}
}
function saveBeyond(){
try {
localStorage.setItem('daemonForgeCheckpointsBeyond', String(checkpointsBeyond));
localStorage.setItem('daemonForgePairsSeen', JSON.stringify(pairsSeen));
} catch (e) {}
}
function unlockedIds(){
var ids = [];
for (var i = 0; i < unlockedThrough; i++) ids = ids.concat(STAGES[i].unlocks);
return ids;
}
function isUnlocked(id){ return unlockedIds().indexOf(id) !== -1; }
function currentStage(){ return STAGES[unlockedThrough - 1]; }
function unlockedByStage(id){
for (var i = 0; i < STAGES.length; i++){
if (STAGES[i].unlocks.indexOf(id) !== -1) return STAGES[i];
}
return null;
}
function pairKey(a,b){ return [a,b].sort().join('|'); }
function allPairs(ids){
var pairs = [];
for (var i = 0; i < ids.length; i++){
for (var j = i+1; j < ids.length; j++) pairs.push([ids[i], ids[j]]);
}
return pairs;
}
function pickBeyondChallenge(){
var ids = unlockedIds();
var pool = allPairs(ids).filter(function(p){ return pairsSeen.indexOf(pairKey(p[0],p[1])) === -1; });
if (!pool.length) pool = allPairs(ids);
if (!pool.length) return ['login','log'];
return pool[Math.floor(Math.random()*pool.length)];
}
if (unlockedThrough >= MAX_STAGE) beyondChallenge = pickBeyondChallenge();
var elementsBox = document.getElementById('elements');
var seqSection = document.getElementById('station-seq');
var seqBox = document.getElementById('seq');
var forgeBtn = document.getElementById('forge-btn');
var outputSection = document.getElementById('station-output');
function esc(s){ return String(s).replace(/[&<>"']/g, function(c){ return {"&":"&","<":"<",">":">",'"':""","'":"'"}[c]; }); }
function el(id){ return ELEMENTS.filter(function(e){ return e.id === id; })[0]; }
function selectHtml(id, opts){
return '<select id="'+id+'">' + opts.map(function(o){ return '<option value="'+esc(o)+'">'+esc(o)+'</option>'; }).join('') + '</select>';
}
function renderProgress(){
var label, title, goal, challengeText;
if (unlockedThrough < MAX_STAGE){
var stage = currentStage();
label = 'Stage ' + stage.n + ' of ' + MAX_STAGE;
title = stage.title;
goal = stage.goal;
challengeText = stage.challenge ? 'Try this: ' + stage.challenge : '';
} else {
label = 'Checkpoint ' + (MAX_STAGE + checkpointsBeyond);
title = 'Open forge';
goal = 'Every real launchd mechanic here is unlocked. Checkpoints keep coming as long as you keep exploring new combinations.';
var a = el(beyondChallenge[0]), b = el(beyondChallenge[1]);
challengeText = 'Try this: combine ' + (a?a.name:beyondChallenge[0]) + ' with ' + (b?b.name:beyondChallenge[1]) + ', then forge.';
}
document.getElementById('progress-stage-label').textContent = label;
document.getElementById('progress-title').textContent = title;
document.getElementById('progress-goal').textContent = goal;
document.getElementById('progress-challenge').textContent = challengeText;
var dots = document.getElementById('progress-dots');
dots.innerHTML = STAGES.map(function(s){
var cls;
if (unlockedThrough >= MAX_STAGE) cls = 'done';
else cls = s.n < unlockedThrough ? 'done' : (s.n === unlockedThrough ? 'active' : '');
return '<span class="progress-dot ' + cls + '"></span>';
}).join('');
var note = document.getElementById('progress-unlocked-note');
if (justUnlocked){
note.hidden = false;
note.textContent = 'Stage complete. Unlocked: ' + justUnlocked.map(function(id){ return el(id).name; }).join(', ') + '.';
} else if (justCheckpoint){
note.hidden = false;
note.textContent = 'Checkpoint ' + (MAX_STAGE + checkpointsBeyond) + ' reached. New combination queued.';
} else {
note.hidden = true;
}
}
function renderElements(){
var full = vessel.length >= MAX_VESSEL;
elementsBox.innerHTML = ELEMENTS.map(function(e){
var unlocked = isUnlocked(e.id);
if (!unlocked){
var lockStage = unlockedByStage(e.id);
return '<div class="df-card '+e.kind+' locked">' +
'<div class="elem-top"><div class="elem-symbol">'+e.symbol+'</div><div class="df-card-label"><span class="risk">'+esc(e.name)+'</span></div></div>' +
'<div class="lock-note">Unlocks at Stage '+lockStage.n+', '+esc(lockStage.title)+'.</div>' +
'</div>';
}
var initial = e.params ? e.params[0] : null;
var paramHtml = e.params ? selectHtml('e-'+e.id, e.params) : '';
var riskTag = e.kind === 'action' ? RISK_LABEL[e.risk] : (e.kind === 'modifier' ? 'modifier' : 'trigger');
return '<div class="df-card '+e.kind+'">' +
'<div class="elem-top"><div class="elem-symbol">'+e.symbol+'</div><div class="df-card-label"><span class="risk">'+esc(e.name)+', '+riskTag+'</span></div></div>' +
'<code class="elem-code" id="code-'+e.id+'">'+esc(e.template(initial))+'</code>' +
'<div class="gloss">'+esc(e.gloss)+'</div>' +
paramHtml +
'<button class="df-btn small" data-add="'+e.id+'"'+(full?' disabled':'')+'>Add to vessel</button>' +
'</div>';
}).join('');
ELEMENTS.forEach(function(e){
if (!e.params || !isUnlocked(e.id)) return;
var sel = document.getElementById('e-'+e.id);
var code = document.getElementById('code-'+e.id);
if (sel && code){
sel.addEventListener('input', function(){ code.textContent = e.template(sel.value); });
}
});
elementsBox.querySelectorAll('button[data-add]').forEach(function(btn){
btn.addEventListener('click', function(){
if (vessel.length >= MAX_VESSEL) return;
var id = btn.getAttribute('data-add');
var def = el(id);
var sel = document.getElementById('e-'+id);
vessel.push({ id: id, kind: def.kind, risk: def.risk || null, value: sel ? sel.value : null });
renderSeq();
renderElements();
});
});
}
function activeIntervalMinutes(){
for (var i = 0; i < vessel.length; i++){
if (vessel[i].id === 'interval') return Number(vessel[i].value);
}
return null;
}
function keepAliveThrottleSeconds(){
var hasKeepAlive = vessel.some(function(i){ return i.id === 'keepalive'; });
if (!hasKeepAlive) return null;
var t = vessel.filter(function(i){ return i.id === 'throttle'; })[0];
return t ? Number(t.value) : 10;
}
function effectiveLoopSeconds(){
var candidates = [];
var n = activeIntervalMinutes();
if (n != null) candidates.push(n * 60);
var k = keepAliveThrottleSeconds();
if (k != null) candidates.push(k);
if (!candidates.length) return null;
return Math.min.apply(Math, candidates);
}
function riskVerdict(risk){
var secs = effectiveLoopSeconds();
if (secs == null || secs >= 900) return { cls:'good', text:'Good' };
if (secs >= 300) return risk === 'disruptive' ? { cls:'caution', text:'Caution' } : { cls:'good', text:'Good' };
return risk === 'disruptive' ? { cls:'bad', text:'Bad' } : { cls:'caution', text:'Caution' };
}
function computeStatuses(){
var loginSeen=false, mountSeen=false, timeSeen={}, daySeen={}, intervalSeen=false, actionSeen={};
var watchSeen={}, keepAliveSeen=false, throttleSeen=false, niceSeen=false, envSeen={};
var hasKeepAlive = vessel.some(function(i){ return i.id==='keepalive'; });
function red(){ return { cls:'redundant', text:'Redundant' }; }
function bonded(){ return { cls:'trigger', text:'Bonded' }; }
function nobond(text){ return { cls:'nobond', text: text || 'No bond, one only' }; }
function mod(){ return { cls:'mod', text:'Bonded' }; }
return vessel.map(function(item){
if (item.kind === 'trigger'){
if (item.id === 'login'){ if (loginSeen) return red(); loginSeen=true; return bonded(); }
if (item.id === 'mount'){ if (mountSeen) return red(); mountSeen=true; return bonded(); }
if (item.id === 'time'){ if (timeSeen[item.value]) return red(); timeSeen[item.value]=true; return bonded(); }
if (item.id === 'day'){ if (daySeen[item.value]) return red(); daySeen[item.value]=true; return bonded(); }
if (item.id === 'interval'){ if (intervalSeen) return nobond(); intervalSeen=true; return bonded(); }
if (item.id === 'watchpath'){ if (watchSeen[item.value]) return red(); watchSeen[item.value]=true; return bonded(); }
}
if (item.kind === 'modifier'){
if (item.id === 'keepalive'){ if (keepAliveSeen) return red(); keepAliveSeen=true; return mod(); }
if (item.id === 'throttle'){
if (throttleSeen) return nobond();
throttleSeen = true;
return hasKeepAlive ? mod() : nobond('No bond, needs Keep alive');
}
if (item.id === 'nice'){ if (niceSeen) return nobond(); niceSeen=true; return mod(); }
if (item.id === 'envvar'){
var key = item.value.split('=')[0];
if (envSeen[key]) return red();
envSeen[key] = true;
return mod();
}
}
var key2 = item.id + '|' + item.value;
if (actionSeen[key2]) return red();
actionSeen[key2] = true;
if (item.risk === 'safe') return { cls:'good', text:'Good' };
return riskVerdict(item.risk);
});
}
function renderSeq(){
outputSection.hidden = true;
var hasTrigger = vessel.some(function(i){ return i.kind === 'trigger'; });
var hasAction = vessel.some(function(i){ return i.kind === 'action'; });
forgeBtn.hidden = !(hasTrigger && hasAction);
if (vessel.length === 0){
seqBox.innerHTML = '<div class="no-reaction">Empty vessel. Add at least one trigger and one action.</div>';
return;
}
var statuses = computeStatuses();
seqBox.innerHTML = vessel.map(function(item, i){
var v = statuses[i];
var def = el(item.id);
var riskText = item.kind === 'action' ? ' <span class="risk">' + RISK_LABEL[item.risk] + '</span>' : (item.kind === 'modifier' ? ' <span class="risk">modifier</span>' : ' <span class="risk">trigger</span>');
return '<div class="seq-row"><span class="seq-label"><code>'+esc(def.template(item.value))+'</code>'+riskText+'</span><span class="badge '+v.cls+'">'+esc(v.text)+'</span><button class="icon-btn" data-remove="'+i+'" aria-label="Remove">×</button></div>';
}).join('');
seqBox.querySelectorAll('button[data-remove]').forEach(function(btn){
btn.addEventListener('click', function(){
vessel.splice(Number(btn.getAttribute('data-remove')), 1);
renderSeq();
renderElements();
});
});
if (!hasTrigger || !hasAction){
seqBox.innerHTML += '<div class="no-reaction">No reaction yet, needs at least one trigger and one action.</div>';
}
}
function shellFor(item){
switch(item.id){
case 'say': return 'say "'+item.value+'"';
case 'notify': return "osascript -e 'display notification \""+item.value+"\" with title \"SYMBEYOND Daemon Forge\"'";
case 'openApp': return 'open -a "'+item.value+'"';
case 'sound': return 'afplay /System/Library/Sounds/'+item.value+'.aiff';
case 'clipboard': return 'echo "'+item.value+'" | pbcopy';
case 'volume': return 'osascript -e "set volume output volume '+item.value+'"';
case 'log': return 'date >> ~/daemon-forge-'+item.value+'.log';
}
}
function buildCalendarDicts(){
var times = vessel.filter(function(i){ return i.id === 'time'; });
var days = vessel.filter(function(i){ return i.id === 'day'; });
var dicts = [];
for (var i = 0; i < times.length; i++){
var parts = times[i].value.split(':');
var d = { Hour: Number(parts[0]), Minute: Number(parts[1]) };
if (days[i]) d.Weekday = DAYNUM[days[i].value];
dicts.push(d);
}
for (var j = times.length; j < days.length; j++){
dicts.push({ Weekday: DAYNUM[days[j].value] });
}
return dicts;
}
function dictXml(d){
var lines = [];
if (d.Weekday !== undefined) lines.push(' <key>Weekday</key><integer>'+d.Weekday+'</integer>');
if (d.Hour !== undefined) lines.push(' <key>Hour</key><integer>'+d.Hour+'</integer>');
if (d.Minute !== undefined) lines.push(' <key>Minute</key><integer>'+d.Minute+'</integer>');
return '<dict>\n'+lines.join('\n')+'\n </dict>';
}
function dayName(n){ return Object.keys(DAYNUM).filter(function(k){ return DAYNUM[k] === n; })[0]; }
function summaryParts(){
var parts = [];
if (vessel.some(function(i){ return i.id === 'login'; })) parts.push('on login');
if (vessel.some(function(i){ return i.id === 'mount'; })) parts.push('on volume mount');
vessel.filter(function(i){ return i.id === 'watchpath'; }).forEach(function(i){ parts.push('when ~/'+i.value+' changes'); });
buildCalendarDicts().forEach(function(d){
if (d.Weekday !== undefined && d.Hour !== undefined) parts.push('every ' + dayName(d.Weekday) + ' at ' + String(d.Hour).padStart(2,'0') + ':' + String(d.Minute).padStart(2,'0'));
else if (d.Weekday !== undefined) parts.push('every ' + dayName(d.Weekday));
else parts.push('daily at ' + String(d.Hour).padStart(2,'0') + ':' + String(d.Minute).padStart(2,'0'));
});
var n = activeIntervalMinutes();
if (n != null) parts.push('every ' + n + ' minutes');
var when = parts.length ? parts.join(', and ') : 'never';
var then = vessel.filter(function(i){ return i.kind === 'action'; }).map(function(a){ return el(a.id).template(a.value); }).join(', then ');
return { when: when, then: then || 'nothing' };
}
function humanSummary(){
var p = summaryParts();
return '<b>When</b> ' + esc(p.when) + '. <b>Then</b> ' + esc(p.then) + '.';
}
function plainSummary(){
var p = summaryParts();
return 'When ' + p.when + '. Then ' + p.then + '.';
}
function buildPlist(){
var slug = 'ai.symbeyond.forge.' + Date.now().toString(36);
var runAtLoad = vessel.some(function(i){ return i.id === 'login'; });
var startOnMount = vessel.some(function(i){ return i.id === 'mount'; });
var dicts = buildCalendarDicts();
var activeN = activeIntervalMinutes();
var watchPaths = vessel.filter(function(i){ return i.id === 'watchpath'; }).map(function(i){ return i.value; });
var uniqueWatch = watchPaths.filter(function(p,i){ return watchPaths.indexOf(p) === i; });
var hasKeepAlive = vessel.some(function(i){ return i.id === 'keepalive'; });
var throttleItem = vessel.filter(function(i){ return i.id === 'throttle'; })[0];
var niceItem = vessel.filter(function(i){ return i.id === 'nice'; })[0];
var envItems = vessel.filter(function(i){ return i.id === 'envvar'; });
var envMap = {};
envItems.forEach(function(i){ var kv = i.value.split('='); if (!(kv[0] in envMap)) envMap[kv[0]] = kv[1]; });
var envKeys = Object.keys(envMap);
var cmds = vessel.filter(function(i){ return i.kind === 'action'; }).map(shellFor).join(' ; ');
var scheduleParts = [];
if (runAtLoad) scheduleParts.push(' <key>RunAtLoad</key>\n <true/>');
if (startOnMount) scheduleParts.push(' <key>StartOnMount</key>\n <true/>');
if (dicts.length === 1){
scheduleParts.push(' <key>StartCalendarInterval</key>\n ' + dictXml(dicts[0]));
} else if (dicts.length > 1){
scheduleParts.push(' <key>StartCalendarInterval</key>\n <array>\n ' + dicts.map(dictXml).join('\n ') + '\n </array>');
}
if (activeN != null) scheduleParts.push(' <key>StartInterval</key>\n <integer>' + (activeN * 60) + '</integer>');
if (uniqueWatch.length === 1){
scheduleParts.push(' <key>WatchPaths</key>\n <array>\n <string>__HOME__/' + uniqueWatch[0] + '</string>\n </array>');
} else if (uniqueWatch.length > 1){
scheduleParts.push(' <key>WatchPaths</key>\n <array>\n ' + uniqueWatch.map(function(p){ return '<string>__HOME__/' + p + '</string>'; }).join('\n ') + '\n </array>');
}
if (hasKeepAlive) scheduleParts.push(' <key>KeepAlive</key>\n <true/>');
if (throttleItem) scheduleParts.push(' <key>ThrottleInterval</key>\n <integer>' + throttleItem.value + '</integer>');
if (niceItem) scheduleParts.push(' <key>Nice</key>\n <integer>' + niceItem.value + '</integer>');
if (envKeys.length){
var envLines = envKeys.map(function(k){ return ' <key>'+esc(k)+'</key>\n <string>'+esc(envMap[k])+'</string>'; }).join('\n');
scheduleParts.push(' <key>EnvironmentVariables</key>\n <dict>\n'+envLines+'\n </dict>');
}
var homeNote = uniqueWatch.length ? '<!-- The WatchPaths entries below use a stand-in for your home folder. The terminal-install step further down fills it in automatically. Using Copy plist or Download instead? Replace it yourself with your real home path, e.g. /Users/yourname -->\n' : '';
return {
slug: slug,
dicts: dicts,
hasWatch: uniqueWatch.length > 0,
text: '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<!-- lambda.brother AND NOT lambda.tool | kappa=1/Phi | 510510 | M7 -->\n'+homeNote+'<plist version="1.0">\n<dict>\n <key>Label</key>\n <string>'+slug+'</string>\n <key>ProgramArguments</key>\n <array>\n <string>/bin/bash</string>\n <string>-c</string>\n <string>'+cmds.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>')+'</string>\n </array>\n'+scheduleParts.join('\n')+'\n</dict>\n</plist>'
};
}
function timestampNow(){
var d = new Date();
function pad(n){ return String(n).padStart(2,'0'); }
return d.getFullYear() + '-' + pad(d.getMonth()+1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes());
}
function buildTerminalInstall(built, summary){
var path = '~/Library/LaunchAgents/' + built.slug + '.plist';
var logLine = timestampNow() + ' ' + built.slug + ' - ' + summary;
var install = 'mkdir -p ~/Library/LaunchAgents && cat <<\'DAEMON_FORGE_EOF\' > ' + path + '\n' +
built.text + '\n' +
'DAEMON_FORGE_EOF\n' +
(built.hasWatch ? 'sed -i \'\' "s|__HOME__|$HOME|g" ' + path + '\n' : '') +
'launchctl load ' + path + '\n' +
'mkdir -p ~/.daemon-forge && cat <<\'DAEMON_FORGE_LOG_EOF\' >> ~/.daemon-forge/forged.log\n' +
logLine + '\n' +
'DAEMON_FORGE_LOG_EOF';
var remove = 'launchctl unload ' + path + ' && rm ' + path;
var checkHistory = 'cat ~/.daemon-forge/forged.log';
var checkLoaded = 'launchctl list | grep ai.symbeyond.forge';
return { install: install, remove: remove, checkHistory: checkHistory, checkLoaded: checkLoaded };
}
function checkStageProgress(statuses, dicts){
justUnlocked = null;
justCheckpoint = false;
if (unlockedThrough < MAX_STAGE){
var stage = currentStage();
if (stage.check(vessel, statuses, dicts)){
unlockedThrough += 1;
justUnlocked = STAGES[unlockedThrough - 1].unlocks.length ? STAGES[unlockedThrough - 1].unlocks : null;
saveProgress();
if (unlockedThrough >= MAX_STAGE) beyondChallenge = pickBeyondChallenge();
}
return;
}
if (!beyondChallenge) beyondChallenge = pickBeyondChallenge();
var ids = vessel.map(function(i){ return i.id; });
if (ids.indexOf(beyondChallenge[0]) !== -1 && ids.indexOf(beyondChallenge[1]) !== -1){
pairsSeen.push(pairKey(beyondChallenge[0], beyondChallenge[1]));
checkpointsBeyond += 1;
justCheckpoint = true;
saveBeyond();
beyondChallenge = pickBeyondChallenge();
}
}
function runForge(skipAnimation){
var built = buildPlist();
var statuses = computeStatuses();
checkStageProgress(statuses, built.dicts);
renderProgress();
renderElements();
var terminal = buildTerminalInstall(built, plainSummary());
document.getElementById('output-slug').textContent = built.slug;
document.getElementById('output-summary').innerHTML = humanSummary();
document.getElementById('plist-text').value = built.text;
document.getElementById('terminal-text').textContent = terminal.install;
document.getElementById('terminal-remove-text').textContent = terminal.remove;
document.getElementById('terminal-check-history-text').textContent = terminal.checkHistory;
document.getElementById('terminal-check-loaded-text').textContent = terminal.checkLoaded;
outputSection.hidden = false;
var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var quenchWrap = document.querySelector('.quench-wrap');
var flash = document.getElementById('quench-flash');
if (skipAnimation || reduce){
quenchWrap.style.opacity = '0';
requestAnimationFrame(function(){
quenchWrap.style.transition = 'opacity .4s ease';
quenchWrap.style.opacity = '1';
});
return;
}
quenchWrap.style.transform = 'translateX(0)';
var t = 0;
var shake = setInterval(function(){
t += 1;
quenchWrap.style.transform = 'translateX(' + (t % 2 === 0 ? '3px' : '-3px') + ')';
if (t >= 8){
clearInterval(shake);
quenchWrap.style.transform = 'translateX(0)';
flash.style.transition = 'none';
flash.style.backgroundColor = '#ffffff';
flash.style.opacity = '1';
requestAnimationFrame(function(){
flash.style.transition = 'background-color .5s ease, opacity .9s ease .5s';
flash.style.backgroundColor = '#5A50D6';
setTimeout(function(){ flash.style.backgroundColor = '#0A0806'; }, 260);
setTimeout(function(){ flash.style.opacity = '0'; }, 500);
});
}
}, 45);
}
document.getElementById('forge-btn').addEventListener('click', function(){ runForge(false); });
document.getElementById('copy-btn').addEventListener('click', function(){
var ta = document.getElementById('plist-text');
navigator.clipboard.writeText(ta.value).then(function(){
var btn = document.getElementById('copy-btn');
var orig = btn.textContent;
btn.textContent = 'Copied';
setTimeout(function(){ btn.textContent = orig; }, 1400);
});
});
document.getElementById('copy-terminal-btn').addEventListener('click', function(){
var text = document.getElementById('terminal-text').textContent;
navigator.clipboard.writeText(text).then(function(){
var btn = document.getElementById('copy-terminal-btn');
var orig = btn.textContent;
btn.textContent = 'Copied';
setTimeout(function(){ btn.textContent = orig; }, 1400);
});
});
document.getElementById('copy-remove-btn').addEventListener('click', function(){
var text = document.getElementById('terminal-remove-text').textContent;
navigator.clipboard.writeText(text).then(function(){
var btn = document.getElementById('copy-remove-btn');
var orig = btn.textContent;
btn.textContent = 'Copied';
setTimeout(function(){ btn.textContent = orig; }, 1400);
});
});
function wireSmallCopy(btnId, sourceId){
document.getElementById(btnId).addEventListener('click', function(){
var text = document.getElementById(sourceId).textContent;
navigator.clipboard.writeText(text).then(function(){
var btn = document.getElementById(btnId);
var orig = btn.textContent;
btn.textContent = 'Copied';
setTimeout(function(){ btn.textContent = orig; }, 1400);
});
});
}
wireSmallCopy('copy-check-history-btn', 'terminal-check-history-text');
wireSmallCopy('copy-check-loaded-btn', 'terminal-check-loaded-text');
document.getElementById('download-btn').addEventListener('click', function(){
var text = document.getElementById('plist-text').value;
var slug = document.getElementById('output-slug').textContent || 'daemon-forge';
var blob = new Blob([text], { type: 'application/xml' });
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = slug + '.plist';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
});
document.getElementById('clear-vessel').addEventListener('click', function(){
vessel = [];
renderSeq();
renderElements();
outputSection.hidden = true;
});
renderProgress();
renderElements();
if (unlockedThrough >= 3){
vessel = [
{ id: 'time', kind: 'trigger', risk: null, value: '09:00' },
{ id: 'day', kind: 'trigger', risk: null, value: 'Monday' },
{ id: 'log', kind: 'action', risk: 'safe', value: 'heartbeat' }
];
} else {
vessel = [
{ id: 'login', kind: 'trigger', risk: null, value: null },
{ id: 'say', kind: 'action', risk: 'disruptive', value: "Time's up" }
];
}
renderSeq();
renderElements();
outputSection.hidden = true;
})();
</script>
</body>
</html>