-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
737 lines (636 loc) · 24.8 KB
/
index.html
File metadata and controls
737 lines (636 loc) · 24.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M365 CLI — Command-line access to Microsoft 365</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@200;300;400&family=DM+Mono:wght@400&display=swap');
:root {
--bg: #faf9f7;
--text: #2c2a28;
--text-dim: #8a8580;
--text-light: #b0aaa4;
--accent: #0078d4;
--accent-hover: #005a9e;
--border: #e8e4e0;
--surface: #f2f0ed;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'DM Sans', sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
line-height: 1.7;
}
.page {
max-width: 680px;
margin: 0 auto;
padding: 6vh 2rem 8vh;
opacity: 0;
animation: fadeUp 1.4s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
position: relative;
z-index: 1;
}
h1 {
font-weight: 200;
font-size: clamp(1.6rem, 4vw, 2.4rem);
letter-spacing: 0.15em;
text-transform: uppercase;
color: var(--text);
margin-bottom: 0.3em;
}
h1::after {
content: '';
display: block;
width: 32px;
height: 1px;
background: linear-gradient(90deg, var(--border), transparent);
margin-top: 1.2em;
}
.intro {
font-weight: 300;
font-size: clamp(0.88rem, 1.3vw, 0.95rem);
color: var(--text-dim);
font-style: italic;
margin-bottom: 2rem;
line-height: 1.7;
}
h2 {
font-weight: 300;
font-size: clamp(0.85rem, 1.5vw, 1.05rem);
letter-spacing: 0.18em;
text-transform: uppercase;
color: var(--text-dim);
margin: 3rem 0 1.5rem;
}
h3 {
font-weight: 400;
font-size: clamp(1rem, 1.8vw, 1.2rem);
letter-spacing: 0.04em;
color: var(--text);
margin: 2.5rem 0 0.6rem;
}
p {
font-weight: 300;
font-size: clamp(0.88rem, 1.3vw, 0.95rem);
color: var(--text);
margin-bottom: 0.8em;
}
a { color: var(--accent); text-decoration: none; transition: color 0.3s ease; }
a:hover { color: var(--accent-hover); }
code {
font-family: 'DM Mono', monospace;
font-size: 0.85em;
background: var(--surface);
padding: 0.15em 0.4em;
border-radius: 3px;
}
pre {
background: var(--surface);
padding: 1.2em 1.4em;
border-radius: 6px;
overflow-x: auto;
margin: 1em 0 1.5em;
border: 1px solid var(--border);
}
pre code {
background: none;
padding: 0;
font-size: 0.82rem;
line-height: 1.6;
color: var(--text);
}
.callout {
background: var(--surface);
border-left: 3px solid var(--accent);
padding: 1em 1.4em;
border-radius: 4px;
margin: 0 0 2rem;
font-weight: 300;
font-size: clamp(0.84rem, 1.2vw, 0.92rem);
color: var(--text-dim);
line-height: 1.7;
}
.callout strong { color: var(--text); }
.link-out {
display: inline-block;
font-family: 'DM Mono', monospace;
font-size: 0.8rem;
color: var(--text-dim);
border-bottom: 1px solid var(--border);
padding-bottom: 1px;
transition: all 0.3s ease;
}
.link-out:hover { color: var(--accent); border-bottom-color: var(--accent); }
table {
width: 100%;
border-collapse: collapse;
margin: 1em 0 1.5em;
font-size: clamp(0.82rem, 1.2vw, 0.9rem);
}
th {
font-weight: 400;
text-align: left;
padding: 0.6em 0.8em;
border-bottom: 2px solid var(--border);
color: var(--text-dim);
font-size: 0.8rem;
letter-spacing: 0.08em;
text-transform: uppercase;
}
td {
font-weight: 300;
padding: 0.6em 0.8em;
border-bottom: 1px solid var(--border);
}
ul, ol {
font-weight: 300;
font-size: clamp(0.88rem, 1.3vw, 0.95rem);
margin: 0.5em 0 1.2em 1.5em;
color: var(--text);
}
li { margin-bottom: 0.4em; }
.diagram {
font-family: 'DM Mono', monospace;
font-size: 0.82rem;
line-height: 1.6;
color: var(--text-dim);
background: var(--surface);
padding: 1.2em 1.4em;
border-radius: 6px;
border: 1px solid var(--border);
margin: 1em 0 1.5em;
overflow-x: auto;
white-space: pre;
}
@keyframes fadeUp {
from { opacity: 0; transform: translateY(18px); }
to { opacity: 1; transform: translateY(0); }
}
.anchor { text-decoration: none; color: var(--text-light); margin-left: 0.3em; opacity: 0; transition: opacity 0.3s; font-weight: 200; }
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
.anchor:hover { color: var(--accent); }
.badge {
display: inline-block;
font-family: 'DM Mono', monospace;
font-size: 0.7rem;
padding: 0.15em 0.5em;
border-radius: 3px;
background: var(--accent);
color: #fff;
letter-spacing: 0.04em;
vertical-align: middle;
margin-left: 0.4em;
}
.steps {
counter-reset: step;
list-style: none;
margin-left: 0;
padding-left: 0;
}
.steps li {
counter-increment: step;
position: relative;
padding-left: 2.4em;
margin-bottom: 1.2em;
}
.steps li::before {
content: counter(step);
position: absolute;
left: 0;
top: 0.05em;
width: 1.6em;
height: 1.6em;
border-radius: 50%;
background: var(--surface);
border: 1px solid var(--border);
text-align: center;
line-height: 1.6em;
font-size: 0.78rem;
font-weight: 400;
color: var(--text-dim);
}
.platform-tabs {
display: flex;
gap: 0;
margin-bottom: -1px;
}
.platform-tab {
font-family: 'DM Mono', monospace;
font-size: 0.78rem;
padding: 0.5em 1.2em;
background: transparent;
border: 1px solid var(--border);
border-bottom: none;
border-radius: 6px 6px 0 0;
cursor: pointer;
color: var(--text-dim);
transition: all 0.2s;
}
.platform-tab.active[data-platform="mac"] {
background: #2d2d2d;
color: #f0f0f0;
border-color: #2d2d2d;
border-bottom: 1px solid #2d2d2d;
}
.platform-tab.active[data-platform="win"] {
background: #012456;
color: #f0f0f0;
border-color: #012456;
border-bottom: 1px solid #012456;
}
.platform-tab:hover:not(.active) {
color: var(--text);
}
.platform-content { display: none; }
.platform-content.active { display: block; }
#platform-mac .copy-wrap pre {
background: #2d2d2d;
border-color: #3a3a3a;
}
#platform-mac .copy-wrap pre code {
color: #e0e0e0;
}
#platform-mac .copy-btn {
background: #3a3a3a;
border-color: #555;
color: #aaa;
}
#platform-mac .copy-btn:hover {
color: #fff;
border-color: #888;
}
#platform-mac .copy-btn.copied {
color: #58d68d;
border-color: #58d68d;
}
#platform-win .copy-wrap pre {
background: #012456;
border-color: #1b3a6b;
}
#platform-win .copy-wrap pre code {
color: #e8e8e8;
}
#platform-win .copy-btn {
background: #1b3a6b;
border-color: #2a5599;
color: #8cb4e0;
}
#platform-win .copy-btn:hover {
color: #fff;
border-color: #5b9bd5;
}
#platform-win .copy-btn.copied {
color: #58d68d;
border-color: #58d68d;
}
.copy-wrap {
position: relative;
}
.copy-wrap pre {
padding-right: 3em;
white-space: pre-wrap;
word-break: break-all;
}
.copy-btn {
position: absolute;
top: 0.6em;
right: 0.6em;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 4px;
padding: 0.25em 0.5em;
cursor: pointer;
font-family: 'DM Mono', monospace;
font-size: 0.7rem;
color: var(--text-dim);
transition: all 0.2s;
line-height: 1;
}
.copy-btn:hover {
color: var(--accent);
border-color: var(--accent);
}
.copy-btn.copied {
color: #2ea043;
border-color: #2ea043;
}
</style>
</head>
<body>
<div class="page">
<h1 id="m365-cli">M365 CLI</h1>
<p style="font-size: 0.75rem; color: var(--text-light); font-weight: 200; margin-bottom: 2rem;">Updated Apr 1, 2026</p>
<div class="callout"><strong>Internal tool.</strong> M365 CLI gives you command-line access to Microsoft 365 services — Teams, Outlook Mail, Calendar, OneDrive & SharePoint Files, and User Profile. Built in Rust, connects via MCP protocol to Microsoft Graph. 80 actions across 5 services, all from your terminal.</div>
<p class="intro">Install in 30 seconds, authenticate once, then access all of M365 from the command line. Works standalone or as an AI skill for Claude Code, Codex, and other AI agents.</p>
<!-- INSTALL -->
<h2 id="install">Install</h2>
<p>One command to install. The binary goes to <code>~/.local/bin/m365</code> (macOS/Linux) or <code>%LOCALAPPDATA%\m365-cli\m365.exe</code> (Windows).</p>
<div class="platform-tabs">
<button class="platform-tab active" data-platform="mac" onclick="switchPlatform('mac')">macOS / Linux</button>
<button class="platform-tab" data-platform="win" onclick="switchPlatform('win')">Windows</button>
</div>
<div id="platform-mac" class="platform-content active">
<div class="copy-wrap">
<button class="copy-btn" onclick="copyCmd(this)">copy</button>
<pre><code>curl -fsSL https://stttthreeai024313688509.blob.core.windows.net/m365cli/install.sh | bash</code></pre>
</div>
</div>
<div id="platform-win" class="platform-content">
<div class="copy-wrap">
<button class="copy-btn" onclick="copyCmd(this)">copy</button>
<pre><code>irm https://stttthreeai024313688509.blob.core.windows.net/m365cli/install.ps1 | iex</code></pre>
</div>
</div>
<h3 id="login">Login</h3>
<p>After installing, sign in with your Microsoft Entra ID account:</p>
<pre><code>m365 login # Opens browser for Microsoft Entra ID sign-in
m365 status # Verify you're logged in</code></pre>
<p>Tokens are stored locally with restricted file permissions. The CLI auto-refreshes expired tokens — you only need to log in once.</p>
<!-- USAGE -->
<h2 id="usage">Usage</h2>
<p>Every command follows the same pattern:</p>
<pre><code>m365 <service> <action> [key=value ...] [--json]</code></pre>
<ul>
<li>Arguments are <code>key=value</code> pairs — no <code>--</code> prefix</li>
<li>JSON arrays use single quotes: <code>attendees='["user@example.com"]'</code></li>
<li>Use <code>--json</code> for structured output (recommended for scripts and agents)</li>
<li>Use <code>--help</code> on any service or action for parameter details</li>
</ul>
<!-- SERVICES -->
<h2 id="services">Services</h2>
<p>5 services, 80 actions. Each service maps to a Microsoft Graph API surface.</p>
<table>
<thead>
<tr><th>Service</th><th>Actions</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>me</code></td><td>5</td><td>User profile, manager, direct reports</td></tr>
<tr><td><code>teams</code></td><td>24</td><td>Chats, channels, messages, members</td></tr>
<tr><td><code>mail</code></td><td>21</td><td>Search, read, compose, reply, forward, attachments</td></tr>
<tr><td><code>calendar</code></td><td>13</td><td>Events, scheduling, rooms, timezone</td></tr>
<tr><td><code>files</code></td><td>17</td><td>OneDrive & SharePoint file operations</td></tr>
</tbody>
</table>
<!-- EXAMPLES -->
<h2 id="examples">Quick examples</h2>
<h3 id="teams-messaging">Teams messaging</h3>
<pre><code># Send a message
m365 teams post-message chatId="19:xxx@thread.v2" content="Hello!" --json
# List recent messages in a chat
m365 teams list-chat-messages chatId="19:xxx@thread.v2" top=20 --json
# Search across all Teams messages
m365 teams search-teams-messages message="hackathon planning" --json</code></pre>
<h3 id="email">Email</h3>
<pre><code># Search emails with natural language
m365 mail search-messages message="quarterly review from manager" --json
# Read a specific email
m365 mail get-message id="AAMkADA..." --json
# Send an email
m365 mail send-email-with-attachments subject="Update" body="See attached" \
toRecipients='["user@contoso.com"]' --json</code></pre>
<h3 id="calendar">Calendar</h3>
<pre><code># Today's events
m365 calendar list-events startDateTime=2026-03-23T00:00:00 \
endDateTime=2026-03-24T00:00:00 --json
# Find a meeting time
m365 calendar find-meeting-times attendees='["user@contoso.com"]' \
meetingDuration=PT30M --json</code></pre>
<h3 id="files">Files</h3>
<pre><code># Search for a file
m365 files find-file-or-folder searchQuery="quarterly report" --json
# Browse a SharePoint site
m365 files find-site searchQuery="Marketing" --json
m365 files list-document-libraries siteId="<site-id>" --json</code></pre>
<!-- FAVORITES -->
<h2 id="favorites">Favorites — the fast path</h2>
<p>The CLI has a local favorites store that caches frequently-used IDs for contacts, chats, channels, and sites. This eliminates multi-step ID lookups and turns 3-step operations into 1-step.</p>
<table>
<thead>
<tr><th>Type</th><th>Stored Fields</th><th>Used For</th></tr>
</thead>
<tbody>
<tr><td><code>contact</code></td><td>alias, upn, name, user_id, chat_id</td><td>Direct messaging, user lookup</td></tr>
<tr><td><code>chat</code></td><td>alias, chat_id, topic</td><td>Group chat access</td></tr>
<tr><td><code>channel</code></td><td>alias, team_id, channel_id</td><td>Channel messaging</td></tr>
<tr><td><code>site</code></td><td>alias, site_id, site_name</td><td>SharePoint file operations</td></tr>
</tbody>
</table>
<h3 id="favorites-workflow">Before and after</h3>
<div class="diagram">Without favorites (3 steps):
m365 me get-my-details → get userId
m365 teams create-chat chatType=oneOnOne members_upns='[...]' → get chatId
m365 teams post-message chatId=<id> content="Hey!"
With favorites (1 step):
m365 fav get alex → chat_id already there
m365 teams post-message chatId=<chat_id> content="Hey!"</div>
<pre><code># List all favorites
m365 fav list --json
# Search by alias or name
m365 fav get alex --json
# Add a favorite
m365 fav add contact alias=alex upn=alexw@contoso.com name="Alex Wang"
# Sync favorites to OneDrive backup
m365 fav sync</code></pre>
<!-- AI AGENT SKILL -->
<h2 id="skill">Using as an AI agent skill</h2>
<p>The M365 CLI comes with a skill file (<code>SKILL.md</code>) that gives AI agents full knowledge of all 80+ commands, parameters, and common workflows. The skill file is written for agents — it tells the agent how to install, authenticate, and use the CLI on the user's behalf.</p>
<h3 id="agent-setup">Agent setup workflow</h3>
<p>The skill file includes a 6-step setup workflow designed for AI agents to follow. Here's what happens when an agent sets up the CLI for the first time:</p>
<ol class="steps">
<li>
<strong>Run the installer</strong> — the agent launches the one-liner install script. On <strong>macOS</strong>, Gatekeeper may prompt the user to allow the binary. On <strong>Windows</strong>, a UAC elevation prompt appears (needed for Defender exclusion). The agent tells the user to approve any OS-level prompts.
</li>
<li>
<strong>Wait for user confirmation</strong> — the agent pauses and asks the user to confirm the installation completed. The installer may fail silently or need user action.
</li>
<li>
<strong>Verify installation</strong> — the agent checks the binary exists at the expected path (<code>~/.local/bin/m365</code> on macOS/Linux, <code>%LOCALAPPDATA%\m365-cli\m365.exe</code> on Windows) and runs <code>m365 --help</code>. On Windows, Defender may scan the binary before it becomes available — the agent retries a few times with short delays if not found immediately.
</li>
<li>
<strong>Login</strong> — the agent runs <code>m365 login</code> using the <strong>absolute path</strong> to the binary (since PATH may not be updated in the current session). The user completes Microsoft Entra ID sign-in in the browser. The agent verifies with <code>m365 status</code>.
</li>
<li>
<strong>Install the skill file</strong> — the agent places <code>SKILL.md</code> in the appropriate skill directory for the platform:
<table style="margin-top: 0.8em;">
<tbody>
<tr><td><strong>Claude Code</strong></td><td><code>.claude/skills/m365-cli/SKILL.md</code> or <code>claude plugin add</code></td></tr>
<tr><td><strong>Eureka</strong></td><td><code>skills/m365-cli/SKILL.md</code> in the workspace</td></tr>
<tr><td><strong>Others</strong></td><td>Consult agent docs for skill directory location</td></tr>
</tbody>
</table>
</li>
<li>
<strong>Ask the user to restart</strong> — most agents load skill files at startup, so the skill won't be available until the app is restarted. After restart, <code>m365</code> should be on PATH.
</li>
</ol>
<h3 id="agent-usage">Once set up</h3>
<p>After setup, the agent can handle M365 tasks naturally:</p>
<pre><code>> Send a Teams message to Alex saying "meeting at 3pm"
> What emails did I get from my manager today?
> Schedule a 30-min meeting with the team tomorrow morning
> Summarize the last 20 messages in the Project Alpha chat</code></pre>
<div class="callout"><strong>Favorites-first.</strong> The skill instructs agents to always check <code>m365 fav get</code> before any operation that needs an ID. This means the agent resolves "send a message to Alex" in one step instead of three — no user ID lookup, no chat creation, just send.</div>
<!-- ARCHITECTURE -->
<h2 id="architecture">Architecture</h2>
<table>
<thead>
<tr><th>Layer</th><th>Details</th></tr>
</thead>
<tbody>
<tr><td>Language</td><td>Rust</td></tr>
<tr><td>Auth</td><td>OAuth 2.0 + PKCE via Microsoft Entra ID</td></tr>
<tr><td>Transport</td><td>MCP (Model Context Protocol) over SSE to Microsoft's MCP gateway</td></tr>
<tr><td>TLS</td><td>rustls (no OpenSSL dependency)</td></tr>
<tr><td>Token storage</td><td>File-based with restricted permissions</td></tr>
<tr><td>Platforms</td><td>macOS ARM64, Linux x64, Windows x64</td></tr>
</tbody>
</table>
<div class="diagram">┌──────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ m365 CLI │────▶│ MCP Gateway │────▶│ Microsoft Graph │
│ (Rust) │ SSE │ (Microsoft) │ │ APIs │
└──────────────┘ └──────────────────┘ └──────────────────┘
│
▼
┌──────────────┐
│ Favorites │
│ (local JSON)│
└──────────────┘</div>
<!-- BUILDING FROM SOURCE -->
<h2 id="build">Building from source</h2>
<p>The source code is available in the private repository. Contact the maintainer for access.</p>
<pre><code>cargo build --release
# Binary at target/release/m365</code></pre>
<!-- TROUBLESHOOTING -->
<h2 id="troubleshooting">Troubleshooting</h2>
<table>
<thead>
<tr><th>Error</th><th>Fix</th></tr>
</thead>
<tbody>
<tr><td>"Not logged in"</td><td>Run <code>m365 login</code></td></tr>
<tr><td>HTTP 401</td><td>Token expired — CLI auto-refreshes, but if persistent, run <code>m365 login</code></td></tr>
<tr><td>HTTP 403</td><td>Check that your account has the required M365 license</td></tr>
<tr><td>HTTP 504</td><td>Server timeout — retry or reduce results with <code>top</code> parameter</td></tr>
<tr><td>"Unknown action"</td><td>Run <code>m365 <service> --help</code></td></tr>
</tbody>
</table>
</div>
<script>
// Anchor links
document.querySelectorAll('h1, h2, h3, h4').forEach(function(h) {
if (!h.id) h.id = h.textContent.trim().toLowerCase().replace(/[^\w]+/g, '-').replace(/-$/, '');
var a = document.createElement('a');
a.href = '#' + h.id;
a.className = 'anchor';
a.textContent = '#';
h.appendChild(a);
});
// Platform tabs
function switchPlatform(platform) {
document.querySelectorAll('.platform-tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.platform-content').forEach(c => c.classList.remove('active'));
event.target.classList.add('active');
document.getElementById('platform-' + platform).classList.add('active');
}
// Copy button
function copyCmd(btn) {
const code = btn.parentElement.querySelector('code').textContent;
navigator.clipboard.writeText(code).then(() => {
btn.textContent = 'copied';
btn.classList.add('copied');
setTimeout(() => { btn.textContent = 'copy'; btn.classList.remove('copied'); }, 1500);
});
}
</script>
<!-- Ambient nebula effect (same style as Jorge Pereira's page) -->
<script>
(() => {
const PALETTE = [
[0, 120, 212], // Microsoft blue
[0, 99, 177], // darker blue
[16, 110, 190], // mid blue
[0, 150, 214], // light blue
[80, 40, 170], // purple accent
[0, 90, 158], // deep blue
[50, 130, 200], // sky blue
[30, 60, 150], // navy hint
];
const canvas = document.createElement('canvas');
canvas.style.cssText =
'position:fixed;top:0;left:0;width:100%;height:100%;z-index:0;pointer-events:none';
document.body.prepend(canvas);
const ctx = canvas.getContext('2d');
let W, H, cx, cy;
function measure() {
W = canvas.width = innerWidth;
H = canvas.height = innerHeight;
const h1 = document.querySelector('h1');
if (h1) {
const r = h1.getBoundingClientRect();
cx = r.left + r.width / 2;
cy = r.top + scrollY + r.height / 2;
} else {
cx = W / 2;
cy = H * 0.12;
}
}
class Wisp {
constructor() { this.reset(true); }
reset(init) {
this.x = cx + (Math.random() - 0.5) * Math.min(W * 0.5, 480);
this.y = cy + (Math.random() - 0.5) * 100;
this.radius = 70 + Math.random() * 150;
this.life = init ? Math.random() * 550 : 0;
this.maxLife = 420 + Math.random() * 480;
this.vx = (Math.random() - 0.5) * 0.13;
this.vy = (Math.random() - 0.5) * 0.04;
this.angle = Math.random() * Math.PI * 2;
this.aSpeed = 0.0014 + Math.random() * 0.0028;
this.color = PALETTE[(Math.random() * PALETTE.length) | 0];
this.baseA = 0.038 + Math.random() * 0.05;
}
update() {
if (++this.life > this.maxLife) { this.reset(false); return; }
this.angle += this.aSpeed;
this.x += this.vx + Math.sin(this.angle) * 0.15;
this.y += this.vy + Math.cos(this.angle * 0.7) * 0.055;
this.radius += 0.05;
}
draw() {
const p = this.life / this.maxLife;
let a = this.baseA;
if (p < 0.15) a *= p / 0.15;
else if (p > 0.6) a *= (1 - p) / 0.4;
const [r, g, b] = this.color;
const rad = this.radius;
const gr = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, rad);
gr.addColorStop(0, `rgba(${r},${g},${b},${a * 2.4})`);
gr.addColorStop(0.25, `rgba(${r},${g},${b},${a * 1.4})`);
gr.addColorStop(0.6, `rgba(${r},${g},${b},${a * 0.35})`);
gr.addColorStop(1, `rgba(${r},${g},${b},0)`);
ctx.fillStyle = gr;
ctx.fillRect(this.x - rad, this.y - rad, rad * 2, rad * 2);
}
}
measure();
addEventListener('resize', measure);
const wisps = Array.from({ length: 12 }, () => new Wisp());
(function render() {
const fade = Math.max(0, 1 - Math.max(0, scrollY - 40) / 240);
ctx.clearRect(0, 0, W, H);
if (fade > 0.002) {
ctx.globalAlpha = fade;
for (const w of wisps) { w.update(); w.draw(); }
ctx.globalAlpha = 1;
} else {
for (const w of wisps) w.update();
}
requestAnimationFrame(render);
})();
})();
</script>
</body>
</html>