Repository navigation
Expand file tree
/
Copy pathutil.html
More file actions
659 lines (490 loc) · 64 KB
/
Copy pathutil.html
File metadata and controls
659 lines (490 loc) · 64 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
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>threecode/util</title>
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="../nimdoc.out.css?v=2.2.10">
<!-- JS -->
<script type="text/javascript" src="../dochack.js?v=2.2.10"></script>
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">☰</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">threecode/util</h1>
<div class="row">
<div class="three columns">
<div class="theme-select-wrapper">
<label for="theme-select">Theme: </label>
<select id="theme-select" onchange="setTheme(this.value)">
<option value="auto">🌗 Match OS</option>
<option value="dark">🌑 Dark</option>
<option value="light">🌕 Light</option>
</select>
</div>
<div id="global-links">
<ul class="simple">
<li><a id="indexLink" href="../theindex.html">Index</a></li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="search" id="searchInput" oninput="search()"/>
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#BlueFg" title="BlueFg = "\e[34m"">BlueFg</a></li>
<li><a class="reference" href="#BoldOn" title="BoldOn = "\e[1m"">BoldOn</a></li>
<li><a class="reference" href="#BrightWhiteFg" title="BrightWhiteFg = "\e[97m"">BrightWhiteFg</a></li>
<li><a class="reference" href="#CyanFg" title="CyanFg = "\e[36m"">CyanFg</a></li>
<li><a class="reference" href="#GreyFg" title="GreyFg = "\e[38;5;244m"">GreyFg</a></li>
<li><a class="reference" href="#OffWhiteFg" title="OffWhiteFg = "\e[38;5;252m"">OffWhiteFg</a></li>
<li><a class="reference" href="#Reset" title="Reset = "\e[0m"">Reset</a></li>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">applyInlineMd
<li><a class="reference" href="#applyInlineMd%2Cstring" title="applyInlineMd(line: string): string">applyInlineMd(line: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">bundledCaFile
<li><a class="reference" href="#bundledCaFile" title="bundledCaFile(): string">bundledCaFile(): string</a></li>
</ul>
<ul class="simple nested-toc-section">bundledSslContext
<li><a class="reference" href="#bundledSslContext" title="bundledSslContext(): SslContext">bundledSslContext(): SslContext</a></li>
</ul>
<ul class="simple nested-toc-section">charWrapAnsi
<li><a class="reference" href="#charWrapAnsi%2Cstring%2Cint" title="charWrapAnsi(s: string; width: int): seq[string]">charWrapAnsi(s: string; width: int): seq[string]</a></li>
</ul>
<ul class="simple nested-toc-section">clipMiddle
<li><a class="reference" href="#clipMiddle%2Cstring%2Cint%2Cint" title="clipMiddle(s: string; head, tail: int): string">clipMiddle(s: string; head, tail: int): string</a></li>
</ul>
<ul class="simple nested-toc-section">collapseHome
<li><a class="reference" href="#collapseHome%2Cstring" title="collapseHome(path: string): string">collapseHome(path: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">debugOut
<li><a class="reference" href="#debugOut%2Cstring%2Cstring" title="debugOut(msg, tag: string)">debugOut(msg, tag: string)</a></li>
<li><a class="reference" href="#debugOut%2Cstring" title="debugOut(msg: string)">debugOut(msg: string)</a></li>
</ul>
<ul class="simple nested-toc-section">detectMdHeader
<li><a class="reference" href="#detectMdHeader%2Cstring" title="detectMdHeader(line: string): (bool, string)">detectMdHeader(line: string): (bool, string)</a></li>
</ul>
<ul class="simple nested-toc-section">humanBytes
<li><a class="reference" href="#humanBytes%2Cint" title="humanBytes(n: int): string">humanBytes(n: int): string</a></li>
</ul>
<ul class="simple nested-toc-section">humanTokens
<li><a class="reference" href="#humanTokens%2Cint" title="humanTokens(n: int): string">humanTokens(n: int): string</a></li>
</ul>
<ul class="simple nested-toc-section">isBinaryContent
<li><a class="reference" href="#isBinaryContent%2Cstring" title="isBinaryContent(s: string): bool">isBinaryContent(s: string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">isMdFenceLine
<li><a class="reference" href="#isMdFenceLine%2Cstring" title="isMdFenceLine(line: string): bool">isMdFenceLine(line: string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">isMdSepRow
<li><a class="reference" href="#isMdSepRow%2Cstring" title="isMdSepRow(line: string): bool">isMdSepRow(line: string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">isMdTableRow
<li><a class="reference" href="#isMdTableRow%2Cstring" title="isMdTableRow(line: string): bool">isMdTableRow(line: string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">levenshtein
<li><a class="reference" href="#levenshtein%2Cstring%2Cstring" title="levenshtein(a, b: string): int">levenshtein(a, b: string): int</a></li>
</ul>
<ul class="simple nested-toc-section">levenshteinCapped
<li><a class="reference" href="#levenshteinCapped%2Cstring%2Cstring%2Cint" title="levenshteinCapped(a, b: string; cap: int): int">levenshteinCapped(a, b: string; cap: int): int</a></li>
</ul>
<ul class="simple nested-toc-section">looksLikePath
<li><a class="reference" href="#looksLikePath%2Cstring" title="looksLikePath(s: string): bool">looksLikePath(s: string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">renderMdTable
<li><a class="reference" href="#renderMdTable%2Cseq%5Bstring%5D%2Cstring%2Cint" title="renderMdTable(rows: seq[string]; indent = " "; maxWidth = 0): string">renderMdTable(rows: seq[string]; indent = " "; maxWidth = 0): string</a></li>
</ul>
<ul class="simple nested-toc-section">replaceFirst
<li><a class="reference" href="#replaceFirst%2Cstring%2Cstring%2Cstring" title="replaceFirst(s, needle, repl: string): (string, bool)">replaceFirst(s, needle, repl: string): (string, bool)</a></li>
</ul>
<ul class="simple nested-toc-section">resolvePath
<li><a class="reference" href="#resolvePath%2Cstring" title="resolvePath(path: string): string">resolvePath(path: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">safeCwd
<li><a class="reference" href="#safeCwd" title="safeCwd(): string">safeCwd(): string</a></li>
</ul>
<ul class="simple nested-toc-section">sanitizeUtf8
<li><a class="reference" href="#sanitizeUtf8%2Cstring" title="sanitizeUtf8(s: string): string">sanitizeUtf8(s: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">stripPreamble
<li><a class="reference" href="#stripPreamble%2Cstring" title="stripPreamble(s: string): string">stripPreamble(s: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">tokenSlot
<li><a class="reference" href="#tokenSlot%2Cstring%2Cint" title="tokenSlot(icon: string; n: int): string">tokenSlot(icon: string; n: int): string</a></li>
</ul>
<ul class="simple nested-toc-section">userConfigRoot
<li><a class="reference" href="#userConfigRoot" title="userConfigRoot(): string">userConfigRoot(): string</a></li>
</ul>
<ul class="simple nested-toc-section">userDataRoot
<li><a class="reference" href="#userDataRoot" title="userDataRoot(): string">userDataRoot(): string</a></li>
</ul>
<ul class="simple nested-toc-section">utf8ByteCut
<li><a class="reference" href="#utf8ByteCut%2Cstring%2Cint" title="utf8ByteCut(s: string; n: int): string">utf8ByteCut(s: string; n: int): string</a></li>
</ul>
<ul class="simple nested-toc-section">utf8ByteCutEnd
<li><a class="reference" href="#utf8ByteCutEnd%2Cstring%2Cint" title="utf8ByteCutEnd(s: string; n: int): string">utf8ByteCutEnd(s: string; n: int): string</a></li>
</ul>
<ul class="simple nested-toc-section">visibleWidth
<li><a class="reference" href="#visibleWidth%2Cstring" title="visibleWidth(s: string): int">visibleWidth(s: string): int</a></li>
</ul>
<ul class="simple nested-toc-section">wrapAnsi
<li><a class="reference" href="#wrapAnsi%2Cstring%2Cint" title="wrapAnsi(s: string; width: int): seq[string]">wrapAnsi(s: string; width: int): seq[string]</a></li>
</ul>
</ul>
</details>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"></p>
<div class="section" id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="types.html">types</a>, <a class="reference external" href="unicodewidth.html">unicodewidth</a>
</dl>
</div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<div id="BlueFg">
<dt><pre><a href="#BlueFg"><span class="Identifier">BlueFg</span></a> <span class="Other">=</span> <span class="StringLit">"\e[34m"</span></pre></dt>
<dd>
</dd>
</div>
<div id="BoldOn">
<dt><pre><a href="#BoldOn"><span class="Identifier">BoldOn</span></a> <span class="Other">=</span> <span class="StringLit">"\e[1m"</span></pre></dt>
<dd>
</dd>
</div>
<div id="BrightWhiteFg">
<dt><pre><a href="#BrightWhiteFg"><span class="Identifier">BrightWhiteFg</span></a> <span class="Other">=</span> <span class="StringLit">"\e[97m"</span></pre></dt>
<dd>
</dd>
</div>
<div id="CyanFg">
<dt><pre><a href="#CyanFg"><span class="Identifier">CyanFg</span></a> <span class="Other">=</span> <span class="StringLit">"\e[36m"</span></pre></dt>
<dd>
</dd>
</div>
<div id="GreyFg">
<dt><pre><a href="#GreyFg"><span class="Identifier">GreyFg</span></a> <span class="Other">=</span> <span class="StringLit">"\e[38;5;244m"</span></pre></dt>
<dd>
</dd>
</div>
<div id="OffWhiteFg">
<dt><pre><a href="#OffWhiteFg"><span class="Identifier">OffWhiteFg</span></a> <span class="Other">=</span> <span class="StringLit">"\e[38;5;252m"</span></pre></dt>
<dd>
</dd>
</div>
<div id="Reset">
<dt><pre><a href="#Reset"><span class="Identifier">Reset</span></a> <span class="Other">=</span> <span class="StringLit">"\e[0m"</span></pre></dt>
<dd>
</dd>
</div>
</dl>
</div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="applyInlineMd-procs-all">
<div id="applyInlineMd,string">
<dt><pre><span class="Keyword">proc</span> <a href="#applyInlineMd%2Cstring"><span class="Identifier">applyInlineMd</span></a><span class="Other">(</span><span class="Identifier">line</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Strict in-line replacements for <tt class="docutils literal"><span class="pre"><span class="Operator">***</span><span class="Identifier">bold</span><span class="Operator">-</span><span class="Identifier">italic</span><span class="Operator">***</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Operator">**</span><span class="Identifier">bold</span><span class="Operator">**</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Operator">*</span><span class="Identifier">italic</span><span class="Operator">*</span></span></tt> / <tt class="docutils literal"><span class="pre"><span class="Identifier">_italic_</span></span></tt>, and backtick-code. Body text rides the terminal's default foreground (no envelope SGR), so the reverts just cancel bold / italic / underline back to default — no need to re-engage <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">x1b</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Identifier">m</span></span></tt> (we no longer dim the body). Bold and inline code: <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">x1b</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Identifier">m</span></span></tt> (bold/bright). Italic: <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">x1b</span><span class="Punctuation">[</span><span class="DecNumber">3</span><span class="Identifier">m</span></span></tt> plus <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">x1b</span><span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Identifier">m</span></span></tt> so it shows on terminals whose monospace font lacks an italic face (italic alone would be invisible there). Strict matching: opening delimiter must be immediately followed by a non-space, closing delimiter immediately preceded by a non-space, and the inner span must not contain the delimiter. Italic additionally requires whitespace/punctuation flanking on the outside, so <tt class="docutils literal"><span class="pre"><span class="Identifier">snake_case</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="DecNumber">5</span><span class="Operator">*</span><span class="DecNumber">5</span></span></tt> survive untouched. Unmatched / malformed markers pass through verbatim.
</dd>
</div>
</div>
<div id="bundledCaFile-procs-all">
<div id="bundledCaFile">
<dt><pre><span class="Keyword">proc</span> <a href="#bundledCaFile"><span class="Identifier">bundledCaFile</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Path to the <tt class="docutils literal"><span class="pre"><span class="Identifier">cacert</span><span class="Operator">.</span><span class="Identifier">pem</span></span></tt> we ship alongside the binary on macOS / Windows (see <tt class="docutils literal"><span class="pre"><span class="Identifier">release</span><span class="Operator">.</span><span class="Identifier">yml</span></span></tt>). Returns "" when not present (Linux release tarball, dev builds) — <tt class="docutils literal"><span class="pre"><span class="Identifier">newContext</span></span></tt> will scan default system cert locations in that case, which works on every Linux distro.
</dd>
</div>
</div>
<div id="bundledSslContext-procs-all">
<div id="bundledSslContext">
<dt><pre><span class="Keyword">proc</span> <a href="#bundledSslContext"><span class="Identifier">bundledSslContext</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">SslContext</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">LibraryError</span><span class="Other">,</span> <span class="Identifier">SslError</span><span class="Other">,</span>
<span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Drop-in <tt class="docutils literal"><span class="pre"><span class="Identifier">SslContext</span></span></tt> for <tt class="docutils literal"><span class="pre"><span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Identifier">sslContext</span> <span class="Operator">=</span> <span class="Operator">...</span><span class="Punctuation">)</span></span></tt> and anywhere else a TLS context is consumed. macOS/Windows ship OpenSSL whose <tt class="docutils literal"><span class="pre"><span class="Identifier">OPENSSLDIR</span></span></tt> is baked to a build-runner path that doesn't exist on user systems, so <tt class="docutils literal"><span class="pre"><span class="Identifier">verifyMode</span> <span class="Operator">=</span> <span class="Identifier">CVerifyPeer</span></span></tt> can't scan the default location — we feed <tt class="docutils literal"><span class="pre"><span class="Identifier">cacert</span><span class="Operator">.</span><span class="Identifier">pem</span></span></tt> from next to the binary. Linux passes <tt class="docutils literal"><span class="pre"><span class="Identifier">caFile</span> <span class="Operator">=</span> <span class="StringLit">""</span></span></tt> and falls through to the system trust store. The <tt class="docutils literal"><span class="pre"><span class="Identifier">streamhttp</span></span></tt> SSE path takes <tt class="docutils literal"><span class="pre"><span class="Identifier">bundledCaFile</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt> directly (it builds its own context internally), so the bundle wiring lives in one place either way.
</dd>
</div>
</div>
<div id="charWrapAnsi-procs-all">
<div id="charWrapAnsi,string,int">
<dt><pre><span class="Keyword">proc</span> <a href="#charWrapAnsi%2Cstring%2Cint"><span class="Identifier">charWrapAnsi</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">width</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Character-wrap: break at exactly <tt class="docutils literal"><span class="pre"><span class="Identifier">width</span></span></tt> visible columns, even mid-word. ANSI CSI escapes pass through without counting toward width. Lines that fit are returned as-is.
</dd>
</div>
</div>
<div id="clipMiddle-procs-all">
<div id="clipMiddle,string,int,int">
<dt><pre><span class="Keyword">proc</span> <a href="#clipMiddle%2Cstring%2Cint%2Cint"><span class="Identifier">clipMiddle</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">head</span><span class="Other">,</span> <span class="Identifier">tail</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="collapseHome-procs-all">
<div id="collapseHome,string">
<dt><pre><span class="Keyword">proc</span> <a href="#collapseHome%2Cstring"><span class="Identifier">collapseHome</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Collapse the user's home dir prefix to <tt class="docutils literal"><span class="pre"><span class="Operator">~/</span></span></tt>. Guards against the <tt class="docutils literal"><span class="pre"><span class="Identifier">getHomeDir</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt> trailing-slash footgun that produced things like <tt class="docutils literal"><span class="pre"><span class="Operator">~</span><span class="Identifier">e</span><span class="Operator">/</span><span class="Identifier">hellodeepseek</span></span></tt> for <tt class="docutils literal"><span class="pre"><span class="Operator">/</span><span class="Identifier">home</span><span class="Operator">/</span><span class="Identifier">carlo</span><span class="Operator">/</span><span class="Identifier">e</span><span class="Operator">/</span><span class="Identifier">hellodeepseek</span></span></tt>.
</dd>
</div>
</div>
<div id="debugOut-procs-all">
<div id="debugOut,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#debugOut%2Cstring%2Cstring"><span class="Identifier">debugOut</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">,</span> <span class="Identifier">tag</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">TimeEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
<div id="debugOut,string">
<dt><pre><span class="Keyword">proc</span> <a href="#debugOut%2Cstring"><span class="Identifier">debugOut</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">TimeEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="detectMdHeader-procs-all">
<div id="detectMdHeader,string">
<dt><pre><span class="Keyword">proc</span> <a href="#detectMdHeader%2Cstring"><span class="Identifier">detectMdHeader</span></a><span class="Other">(</span><span class="Identifier">line</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><span class="Identifier">bool</span><span class="Other">,</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
A line of <tt class="docutils literal"><span class="pre"><span class="Comment">###...</span></span></tt> followed by a space and at least one non-space char. Returns (true, body) on match, (false, "") otherwise.
</dd>
</div>
</div>
<div id="humanBytes-procs-all">
<div id="humanBytes,int">
<dt><pre><span class="Keyword">proc</span> <a href="#humanBytes%2Cint"><span class="Identifier">humanBytes</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="humanTokens-procs-all">
<div id="humanTokens,int">
<dt><pre><span class="Keyword">proc</span> <a href="#humanTokens%2Cint"><span class="Identifier">humanTokens</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="isBinaryContent-procs-all">
<div id="isBinaryContent,string">
<dt><pre><span class="Keyword">proc</span> <a href="#isBinaryContent%2Cstring"><span class="Identifier">isBinaryContent</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Scan the first 512 bytes for binary indicators: any NUL byte, or<blockquote class="markdown-quote"><p>5% non-printable control chars (excluding t n r).</p></blockquote>
</dd>
</div>
</div>
<div id="isMdFenceLine-procs-all">
<div id="isMdFenceLine,string">
<dt><pre><span class="Keyword">proc</span> <a href="#isMdFenceLine%2Cstring"><span class="Identifier">isMdFenceLine</span></a><span class="Other">(</span><span class="Identifier">line</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<pre class="listing"> <span class="Punctuation">`</span><span class="Punctuation">`</span><span class="Punctuation">`</span></pre> (3+ backticks, optional language label after).
</dd>
</div>
</div>
<div id="isMdSepRow-procs-all">
<div id="isMdSepRow,string">
<dt><pre><span class="Keyword">proc</span> <a href="#isMdSepRow%2Cstring"><span class="Identifier">isMdSepRow</span></a><span class="Other">(</span><span class="Identifier">line</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Detect the <tt class="docutils literal"><span class="pre"><span class="Operator">|---|:---:|---:|</span></span></tt> alignment-separator row between header and body — its cells contain only <tt class="docutils literal"><span class="pre"><span class="Operator">-</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Punctuation">:</span></span></tt>, and spaces.
</dd>
</div>
</div>
<div id="isMdTableRow-procs-all">
<div id="isMdTableRow,string">
<dt><pre><span class="Keyword">proc</span> <a href="#isMdTableRow%2Cstring"><span class="Identifier">isMdTableRow</span></a><span class="Other">(</span><span class="Identifier">line</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
A markdown-table row both opens and closes with a <tt class="docutils literal"><span class="pre"><span class="Operator">|</span></span></tt>. Rejects bare prose that happens to contain a pipe.
</dd>
</div>
</div>
<div id="levenshtein-procs-all">
<div id="levenshtein,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#levenshtein%2Cstring%2Cstring"><span class="Identifier">levenshtein</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">int</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="levenshteinCapped-procs-all">
<div id="levenshteinCapped,string,string,int">
<dt><pre><span class="Keyword">proc</span> <a href="#levenshteinCapped%2Cstring%2Cstring%2Cint"><span class="Identifier">levenshteinCapped</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">cap</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">int</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Standard edit distance with an early cutoff: returns <tt class="docutils literal"><span class="pre"><span class="Identifier">cap</span><span class="Operator">+</span><span class="DecNumber">1</span></span></tt> once the minimum row value exceeds <tt class="docutils literal"><span class="pre"><span class="Identifier">cap</span></span></tt>. Cap keeps the cost linear-ish for the "compare against every file line" use case.
</dd>
</div>
</div>
<div id="looksLikePath-procs-all">
<div id="looksLikePath,string">
<dt><pre><span class="Keyword">proc</span> <a href="#looksLikePath%2Cstring"><span class="Identifier">looksLikePath</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Heuristic for the path-on-its-own-line preceding a write/patch fence in text mode. Rejects prose (whitespace inside, fence markers, headings). Accepts anything containing <tt class="docutils literal"><span class="pre"><span class="Operator">/</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Operator">.</span></span></tt> — paths typically have one.
</dd>
</div>
</div>
<div id="renderMdTable-procs-all">
<div id="renderMdTable,seq[string],string,int">
<dt><pre><span class="Keyword">proc</span> <a href="#renderMdTable%2Cseq%5Bstring%5D%2Cstring%2Cint"><span class="Identifier">renderMdTable</span></a><span class="Other">(</span><span class="Identifier">rows</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">indent</span> <span class="Other">=</span> <span class="StringLit">" "</span><span class="Other">;</span> <span class="Identifier">maxWidth</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Render a buffered markdown table as an aligned, box-drawn block. Each output line is prefixed with <tt class="docutils literal"><span class="pre"><span class="Identifier">indent</span></span></tt> so the table sits in the harness's col-2 content area. Skips the alignment-separator row but uses it as the header/body divider when present.</p>
<p>When <tt class="docutils literal"><span class="pre"><span class="Identifier">maxWidth</span> <span class="Operator">></span> <span class="DecNumber">0</span></span></tt>, the natural column widths are compressed to fit <tt class="docutils literal"><span class="pre"><span class="Identifier">maxWidth</span></span></tt> total columns: the widest column is shaved by one visible char at a time until the row fits, never going below a per-column minimum of <tt class="docutils literal"><span class="pre"><span class="Identifier">MinCol</span></span></tt>. Cells longer than their column are word-wrapped across multiple visual lines so the row stays readable. If even <tt class="docutils literal"><span class="pre"><span class="Identifier">MinCol</span></span></tt> per column doesn't fit (too many columns for the terminal), the table degrades to a vertical <tt class="docutils literal"><span class="pre"><span class="Identifier">label</span><span class="Punctuation">:</span> <span class="Identifier">value</span></span></tt> rendering: readable, no overflow, but loses the grid.</p>
</dd>
</div>
</div>
<div id="replaceFirst-procs-all">
<div id="replaceFirst,string,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#replaceFirst%2Cstring%2Cstring%2Cstring"><span class="Identifier">replaceFirst</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">,</span> <span class="Identifier">needle</span><span class="Other">,</span> <span class="Identifier">repl</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><span class="Identifier">string</span><span class="Other">,</span> <span class="Identifier">bool</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="resolvePath-procs-all">
<div id="resolvePath,string">
<dt><pre><span class="Keyword">proc</span> <a href="#resolvePath%2Cstring"><span class="Identifier">resolvePath</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="safeCwd-procs-all">
<div id="safeCwd">
<dt><pre><span class="Keyword">proc</span> <a href="#safeCwd"><span class="Identifier">safeCwd</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
The current working directory, or <tt class="docutils literal"><span class="pre">/</span></tt> when the process's cwd has been removed or renamed out from under it. Nim's <tt class="docutils literal"><span class="pre">getCurrentDir</span></tt> raises <tt class="docutils literal"><span class="pre">OSError</span></tt> in that case (Linux <tt class="docutils literal"><span class="pre">getcwd</span></tt> returns <tt class="docutils literal"><span class="pre">ENOENT</span></tt>), which would crash the REPL. The filesystem no longer has a name for the deleted dir, so callers that only need an absolute path label for context, logging, or session identity get <tt class="docutils literal"><span class="pre">/</span></tt> — every dir-walk, <tt class="docutils literal"><span class="pre">ls</span></tt>, <tt class="docutils literal"><span class="pre">git</span></tt> and <tt class="docutils literal"><span class="pre">fileExists</span></tt> against it then simply finds nothing and degrades gracefully.
</dd>
</div>
</div>
<div id="sanitizeUtf8-procs-all">
<div id="sanitizeUtf8,string">
<dt><pre><span class="Keyword">proc</span> <a href="#sanitizeUtf8%2Cstring"><span class="Identifier">sanitizeUtf8</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Return a copy of <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> that is valid UTF-8: every invalid byte or malformed sequence is replaced with a single U+FFFD, and every valid codepoint (including multibyte) passes through untouched.</p>
<p>Strings that cross a system boundary into a JSON request body must be valid UTF-8. Tool output and resumed-session text can carry bytes that aren't — e.g. a command that printed a truncated multi-byte rune left a lone continuation byte in its result, which <tt class="docutils literal"><span class="pre"><span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">json</span></span></tt> emits verbatim into the serialized body. The provider then rejects the whole body with a 400, and since the offending message recurs in every subsequent request (tool messages can't be dropped) the session is bricked until the <tt class="docutils literal"><span class="pre"><span class="Operator">.</span><span class="DecNumber">3</span><span class="Identifier">log</span></span></tt> is hand-edited. This is the boundary guard that stops that.</p>
</dd>
</div>
</div>
<div id="stripPreamble-procs-all">
<div id="stripPreamble,string">
<dt><pre><span class="Keyword">proc</span> <a href="#stripPreamble%2Cstring"><span class="Identifier">stripPreamble</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Strip <tt class="docutils literal"><span class="pre"><span class="Operator"><</span><span class="Identifier">session_context</span><span class="Operator">>...</</span><span class="Identifier">session_context</span><span class="Operator">></span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Operator"><</span><span class="Identifier">project_notes</span><span class="Operator">>...</</span><span class="Identifier">project_notes</span><span class="Operator">></span></span></tt> blocks from a stored user message so the replay UI shows the prompt the user typed, not the auto-injected context the model needs. Only acts on a leading block (<tt class="docutils literal"><span class="pre"><span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">strip</span></span></tt> starts with <tt class="docutils literal"><span class="pre"><span class="Operator"><</span><span class="Identifier">session_context</span><span class="Operator">></span></span></tt>); leaves the string alone if either tag appears mid-message — that would be the user's own text, not our preamble.
</dd>
</div>
</div>
<div id="tokenSlot-procs-all">
<div id="tokenSlot,string,int">
<dt><pre><span class="Keyword">proc</span> <a href="#tokenSlot%2Cstring%2Cint"><span class="Identifier">tokenSlot</span></a><span class="Other">(</span><span class="Identifier">icon</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
"iconvalue" — no space between glyph and number. Slots are joined with two spaces for visual separation. When the value is 0 the slot is omitted entirely (returns ""); the caller strips the preceding spacer too so no dangling gaps appear.
</dd>
</div>
</div>
<div id="userConfigRoot-procs-all">
<div id="userConfigRoot">
<dt><pre><span class="Keyword">proc</span> <a href="#userConfigRoot"><span class="Identifier">userConfigRoot</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
XDG config root for 3code: <tt class="docutils literal"><span class="pre"><span class="Operator">~/.</span><span class="Identifier">config</span><span class="Operator">/</span><span class="DecNumber">3</span><span class="Identifier">code</span><span class="Operator">/</span></span></tt> on Linux, <tt class="docutils literal"><span class="pre"><span class="Operator">~/</span><span class="Identifier">Library</span><span class="Operator">/</span><span class="Identifier">Application</span> <span class="Identifier">Support</span><span class="Operator">/</span><span class="DecNumber">3</span><span class="Identifier">code</span><span class="Operator">/</span></span></tt> on macOS, <tt class="docutils literal"><span class="pre"><span class="Operator">%</span><span class="Identifier">APPDATA</span><span class="Operator">%/</span><span class="DecNumber">3</span><span class="Identifier">code</span><span class="Operator">/</span></span></tt> on Windows. Holds user-edited config and skill overrides only.
</dd>
</div>
</div>
<div id="userDataRoot-procs-all">
<div id="userDataRoot">
<dt><pre><span class="Keyword">proc</span> <a href="#userDataRoot"><span class="Identifier">userDataRoot</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
XDG data root for 3code: <tt class="docutils literal"><span class="pre"><span class="Operator">~/.</span><span class="Identifier">local</span><span class="Operator">/</span><span class="Identifier">share</span><span class="Operator">/</span><span class="DecNumber">3</span><span class="Identifier">code</span><span class="Operator">/</span></span></tt> on Linux, <tt class="docutils literal"><span class="pre"><span class="Operator">~/</span><span class="Identifier">Library</span><span class="Operator">/</span><span class="Identifier">Application</span> <span class="Identifier">Support</span><span class="Operator">/</span><span class="DecNumber">3</span><span class="Identifier">code</span><span class="Operator">/</span></span></tt> on macOS, <tt class="docutils literal"><span class="pre"><span class="Operator">%</span><span class="Identifier">APPDATA</span><span class="Operator">%/</span><span class="DecNumber">3</span><span class="Identifier">code</span><span class="Operator">/</span></span></tt> on Windows (collapses with config-root there — fine, the split is a Linux convention). Holds app-managed state: sessions, history, extracted built-in skills.
</dd>
</div>
</div>
<div id="utf8ByteCut-procs-all">
<div id="utf8ByteCut,string,int">
<dt><pre><span class="Keyword">proc</span> <a href="#utf8ByteCut%2Cstring%2Cint"><span class="Identifier">utf8ByteCut</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Slice <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> to at most <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> bytes, backing up to a UTF-8 codepoint boundary so the result is valid UTF-8. Strings in JSON request bodies must be valid UTF-8 — Pydantic-backed providers (deepinfra) reject the body with "There was an error parsing the body" when a naive byte slice splits a multi-byte rune (e.g. <tt class="docutils literal"><span class="pre"><span class="Identifier">→</span></span></tt> chopped after two bytes).
</dd>
</div>
</div>
<div id="utf8ByteCutEnd-procs-all">
<div id="utf8ByteCutEnd,string,int">
<dt><pre><span class="Keyword">proc</span> <a href="#utf8ByteCutEnd%2Cstring%2Cint"><span class="Identifier">utf8ByteCutEnd</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Take the last up-to-<tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> bytes of <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>, advancing past any leading UTF-8 continuation byte so the result is valid UTF-8. Mirror of <tt class="docutils literal"><span class="pre"><span class="Identifier">utf8ByteCut</span></span></tt> for tail slices (used by <tt class="docutils literal"><span class="pre"><span class="Identifier">clipMiddle</span></span></tt>).
</dd>
</div>
</div>
<div id="visibleWidth-procs-all">
<div id="visibleWidth,string">
<dt><pre><span class="Keyword">proc</span> <a href="#visibleWidth%2Cstring"><span class="Identifier">visibleWidth</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">int</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Count visible columns in a string that may contain ANSI CSI escape sequences (<tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">e</span><span class="Punctuation">[</span><span class="Operator">...<</span><span class="Identifier">letter</span><span class="Operator">></span></span></tt>). Each rune is weighted by its East Asian Width: CJK / emoji count as 2, combining marks as 0.
</dd>
</div>
</div>
<div id="wrapAnsi-procs-all">
<div id="wrapAnsi,string,int">
<dt><pre><span class="Keyword">proc</span> <a href="#wrapAnsi%2Cstring%2Cint"><span class="Identifier">wrapAnsi</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">width</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Greedy word-wrap on whitespace; each chunk's visible width is at most <tt class="docutils literal"><span class="pre"><span class="Identifier">width</span></span></tt>. ANSI CSI escape sequences pass through without counting toward width. Words longer than <tt class="docutils literal"><span class="pre"><span class="Identifier">width</span></span></tt> overflow on their own line — terminal wrap takes them from there. Multiple inter-word spaces collapse to one.
</dd>
</div>
</div>
</dl>
</div>
</div>
</div>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br>
<small style="color: var(--hint);">Made with Nim. Generated: 2026-06-27 09:41:59 UTC</small>
</div>
</div>
</div>
</body>
</html>