@mobius-os/mobius 0.3.62 → 0.3.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobius-os/mobius",
3
- "version": "0.3.62",
3
+ "version": "0.3.64",
4
4
  "type": "module",
5
5
  "description": "Mobius terminal client. Reuses Mobius frontend TypeScript types and jsonl entry shapes.",
6
6
  "bin": {
@@ -12,6 +12,7 @@
12
12
  "start": "tsx src/main.tsx",
13
13
  "typecheck": "tsc --noEmit",
14
14
  "test:integration": "tsx tests/integration.test.ts",
15
+ "test:size": "tsx tests/terminal-size.test.ts",
15
16
  "test:ui": "tsx tests/ui.test.tsx",
16
17
  "test:flow": "tsx tests/flow.test.tsx",
17
18
  "test:resume": "tsx tests/resume.test.tsx",
@@ -21,7 +22,7 @@
21
22
  "test:scroll": "tsx tests/scroll.test.tsx",
22
23
  "test:viewport": "tsx tests/viewport.test.ts",
23
24
  "test:selection": "FORCE_COLOR=1 tsx tests/selection.test.tsx",
24
- "test": "npm run typecheck && npm run test:ui && npm run test:integration"
25
+ "test": "npm run typecheck && npm run test:size && npm run test:ui && npm run test:integration"
25
26
  },
26
27
  "dependencies": {
27
28
  "chalk": "^5.3.0",
@@ -13,8 +13,8 @@ set -euo pipefail
13
13
 
14
14
  TAG=20241002
15
15
  PYVER=3.12.7
16
- BUNDLE_VER=12
17
- AIMUX_VERSION=0.3.62
16
+ BUNDLE_VER=13
17
+ AIMUX_VERSION=0.3.64
18
18
  PYPI_INDEX=https://pypi.org/simple
19
19
  WORK="${WORK:-$HOME/python-bundles}"
20
20
  DIST="${DIST:-$WORK/dist}"
package/src/aimux.ts CHANGED
@@ -32,7 +32,7 @@ export type AimuxLauncher =
32
32
  | { kind: 'exe'; path: string }
33
33
  | { kind: 'module'; python: string }
34
34
 
35
- const AIMUX_TARGET_VERSION = '0.3.62'
35
+ const AIMUX_TARGET_VERSION = '0.3.64'
36
36
  const AIMUX_PACKAGE = `aimux==${AIMUX_TARGET_VERSION}`
37
37
  const WIN = process.platform === 'win32'
38
38
  const venvDir = () => path.join(mobiusHome(), 'aimux-venv')
@@ -93,7 +93,7 @@ async function pythonForAimux(onProgress?: (p: InstallProgress) => void): Promis
93
93
  // 系统 python(如被精简掉 ensurepip 的容器镜像)。aimux 全部依赖为纯 Python,
94
94
  // 故三平台可共用同一套打包产物,分别按 arch 发布到 CDN。
95
95
  /** Plan B 内置运行时包版本;每次发版跟 aimux pin 一起 +1,测试也从这里取。 */
96
- export const BUNDLE_VER = '12'
96
+ export const BUNDLE_VER = '13'
97
97
  const BUNDLE_AIMUX_VERSION = AIMUX_TARGET_VERSION
98
98
  /** Version expected from the installed or bundled AIMUX runtime. */
99
99
  export const AIMUX_VERSION = BUNDLE_AIMUX_VERSION
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Terminal size probe — the Windows width workaround.
3
+ *
4
+ * Two things make `stdout.columns` disagree with the visible window:
5
+ *
6
+ * 1. A missed resize. Windows has no SIGWINCH, so the size only arrives as a
7
+ * console event. The terminal can push that event while Node is still
8
+ * booting (`tsx` takes a beat), i.e. before Ink has attached its listener,
9
+ * and the frame is then laid out with whatever width the process started
10
+ * with — until the user resizes the window by hand and a fresh event lands.
11
+ * 2. A console that reports the wrong size at all. Classic cmd.exe has a screen
12
+ * buffer (120 columns by default) that can be wider than its window, and
13
+ * under ConPTY (Windows Terminal, VS Code, the Win11 default host) the child
14
+ * talks to a pseudo console whose size is only refreshed on a real resize.
15
+ *
16
+ * Either way Ink lays the frame out a few columns too wide (`ink.js`:
17
+ * `stdout.columns || 80`) and the terminal hard-wraps the overflow — text
18
+ * "falls" onto the next row and borders stop lining up.
19
+ *
20
+ * So the probe does both cheap things: re-reads Node's own value (cures 1) and
21
+ * asks the terminal itself with `CSI 18 t` ("report text area size in
22
+ * characters", cures 2). A terminal that never answers is left as it was.
23
+ */
24
+ import { Transform, type TransformCallback } from 'node:stream'
25
+
26
+ /** Ask the terminal to report its text-area size (CSI 18 t). */
27
+ const SIZE_QUERY = '\x1b[18t'
28
+ /** The answer: CSI 8 ; <n> ; <n> t. Which number is height and which is width varies — see interpretSizeReport. */
29
+ const SIZE_REPORT = /\x1b\[8;(\d+);(\d+)t/g
30
+ /**
31
+ * A chunk tail that might still grow into a size report (`\x1b`, `\x1b[`, `\x1b[8;24;80…`).
32
+ * Reports can straddle two reads, so the tail is held for one beat rather than
33
+ * forwarded — otherwise Ink would receive report bytes as junk keystrokes.
34
+ */
35
+ const PARTIAL_REPORT = /^\x1b(\[(\d*;)*\d*)?$/
36
+ const PARTIAL_HOLD_MS = 15
37
+ /** Ignore nonsense sizes rather than handing the layout an unusable width. */
38
+ const MIN_COLUMNS = 20, MAX_COLUMNS = 1000, MIN_ROWS = 5, MAX_ROWS = 500
39
+ const DEFAULT_POLL_MS = 1_000
40
+
41
+ export interface TerminalSize { columns: number; rows: number }
42
+
43
+ /**
44
+ * Pull every complete size report out of `text`, leaving `rest` for the app.
45
+ * The two numbers are returned in the order the terminal sent them; deciding
46
+ * which is which is `interpretSizeReport`'s job.
47
+ */
48
+ export function extractSizeReports(text: string): { reports: Array<[number, number]>; rest: string } {
49
+ const reports: Array<[number, number]> = []
50
+ let rest = ''
51
+ let lastIndex = 0
52
+ SIZE_REPORT.lastIndex = 0
53
+ let match = SIZE_REPORT.exec(text)
54
+ while (match) {
55
+ rest += text.slice(lastIndex, match.index)
56
+ reports.push([Number(match[1]), Number(match[2])])
57
+ lastIndex = match.index + match[0].length
58
+ match = SIZE_REPORT.exec(text)
59
+ }
60
+ rest += text.slice(lastIndex)
61
+ return { reports, rest }
62
+ }
63
+
64
+ /**
65
+ * xterm's ctlseqs says the report is `CSI 8 ; height ; width t`, and Windows
66
+ * Terminal follows that — but not every terminal does: tmux answers width first
67
+ * (measured). Both readings are plausible integers, so take the one closer to
68
+ * what we already believe: this probe only ever corrects a *stale* size, and
69
+ * swapping the axes moves both of them by far more than a stale value does.
70
+ * Ties go to the documented order.
71
+ */
72
+ export function interpretSizeReport(first: number, second: number, current: TerminalSize): TerminalSize {
73
+ const documented: TerminalSize = { rows: first, columns: second }
74
+ const swapped: TerminalSize = { rows: second, columns: first }
75
+ const drift = (size: TerminalSize) => Math.abs(size.columns - current.columns) + Math.abs(size.rows - current.rows)
76
+ return drift(documented) <= drift(swapped) ? documented : swapped
77
+ }
78
+
79
+ function usable({ columns, rows }: TerminalSize): boolean {
80
+ return columns >= MIN_COLUMNS && columns <= MAX_COLUMNS && rows >= MIN_ROWS && rows <= MAX_ROWS
81
+ }
82
+
83
+ /**
84
+ * Wrap `input` in a stream that swallows terminal size reports, applies them (and
85
+ * Node's own size once it moves) to `output`, and nudges Ink's resize handler so
86
+ * the frame is re-laid out. Returns `input` untouched when probing cannot work
87
+ * (no TTY, or explicitly disabled), so callers can use it unconditionally.
88
+ */
89
+ export function createTerminalSizeProbe(
90
+ input: NodeJS.ReadStream,
91
+ output: NodeJS.WriteStream,
92
+ options: { pollMs?: number } = {},
93
+ ): NodeJS.ReadStream {
94
+ if (process.env.MOBIUS_TUI_DISABLE_SIZE_PROBE === '1') return input
95
+ if (!input.isTTY || !output.isTTY || typeof input.setRawMode !== 'function') return input
96
+
97
+ const pollMs = options.pollMs ?? DEFAULT_POLL_MS
98
+ let held = ''
99
+ let holdTimer: ReturnType<typeof setTimeout> | null = null
100
+ let applied: TerminalSize | null = null
101
+ // Our own `emit('resize')` must not be mistaken for a real one and re-ask.
102
+ let applying = false
103
+
104
+ const requestSize = (): void => {
105
+ try { output.write(SIZE_QUERY) } catch { /* terminal went away */ }
106
+ }
107
+
108
+ const nudge = (): void => {
109
+ applying = true
110
+ try { output.emit('resize') } finally { applying = false }
111
+ }
112
+
113
+ const applySize = (size: TerminalSize): void => {
114
+ if (!usable(size)) return
115
+ if (applied && applied.columns === size.columns && applied.rows === size.rows) return
116
+ applied = { columns: size.columns, rows: size.rows }
117
+ // Node keeps columns/rows as writable own properties on a tty stream and
118
+ // updates them the same way, so a plain assignment is enough here.
119
+ output.columns = size.columns
120
+ output.rows = size.rows
121
+ nudge()
122
+ }
123
+
124
+ const onResize = (): void => { if (!applying) requestSize() }
125
+
126
+ // (1) Node's value can move without an event reaching us — after the terminal
127
+ // pushed its size while Ink was still booting, say. A cheap 1s re-read turns
128
+ // "resize the window by hand to fix it" into "it just settles".
129
+ const pollTimer = setInterval(() => {
130
+ if (applying) return
131
+ const columns = output.columns, rows = output.rows
132
+ if (applied && applied.columns === columns && applied.rows === rows) return
133
+ applied = { columns, rows }
134
+ if (usable(applied)) nudge()
135
+ }, pollMs)
136
+ if (typeof pollTimer.unref === 'function') pollTimer.unref()
137
+
138
+ const probe = new Transform({
139
+ transform(chunk: Buffer | string, _encoding: string, callback: TransformCallback) {
140
+ if (holdTimer) { clearTimeout(holdTimer); holdTimer = null }
141
+ const { reports, rest } = extractSizeReports(held + String(chunk))
142
+ held = ''
143
+ for (const [first, second] of reports) {
144
+ applySize(interpretSizeReport(first, second, { columns: output.columns, rows: output.rows }))
145
+ }
146
+ // Hold a tail that could still become a report; forward everything else.
147
+ if (rest.length > 0 && rest.length <= 16 && PARTIAL_REPORT.test(rest)) {
148
+ held = rest
149
+ holdTimer = setTimeout(() => {
150
+ holdTimer = null
151
+ const flushed = held
152
+ held = ''
153
+ if (flushed) probe.push(flushed)
154
+ }, PARTIAL_HOLD_MS)
155
+ callback(null, '')
156
+ return
157
+ }
158
+ callback(null, rest)
159
+ },
160
+ flush(callback: TransformCallback) {
161
+ if (holdTimer) clearTimeout(holdTimer)
162
+ holdTimer = null
163
+ const flushed = held
164
+ held = ''
165
+ callback(null, flushed)
166
+ },
167
+ }) as Transform & Partial<NodeJS.ReadStream>
168
+
169
+ // Mimic the tty surface Ink and the win32 input decoder expect downstream.
170
+ Object.defineProperty(probe, 'isTTY', { value: true })
171
+ Object.defineProperty(probe, 'isRaw', { get: () => input.isRaw })
172
+ probe.setRawMode = (enabled: boolean) => { input.setRawMode?.(enabled); return probe as NodeJS.ReadStream }
173
+ probe.ref = () => { input.ref(); return probe as NodeJS.ReadStream }
174
+ probe.unref = () => { input.unref(); return probe as NodeJS.ReadStream }
175
+
176
+ output.on('resize', onResize)
177
+ // The answer only arrives once the tty is raw — in cooked mode it would sit in
178
+ // the line buffer until the user pressed Enter.
179
+ try { input.setRawMode(true) } catch { /* not a real tty after all */ }
180
+ requestSize()
181
+ input.pipe(probe)
182
+ return probe as NodeJS.ReadStream
183
+ }
package/src/main.tsx CHANGED
@@ -10,8 +10,16 @@ import React from 'react'
10
10
  import { render } from 'ink'
11
11
  import { App } from './App.js'
12
12
  import { createInkInputStream } from './lib/windows-input.js'
13
+ import { createTerminalSizeProbe } from './lib/terminal-size.js'
14
+
15
+ // Ask the terminal for its real text-area size before Ink lays anything out:
16
+ // on Windows (ConPTY, and cmd whose screen buffer is wider than its window) the
17
+ // size Node reports can be a stale, too-wide value until the window is resized
18
+ // by hand. See lib/terminal-size.ts.
19
+ const stdout = process.stdout
20
+ const stdin = createInkInputStream(createTerminalSizeProbe(process.stdin, stdout), stdout)
13
21
 
14
22
  render(React.createElement(App), {
15
23
  exitOnCtrlC: true,
16
- stdin: createInkInputStream(process.stdin, process.stdout),
24
+ stdin,
17
25
  })
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Terminal size probe tests.
3
+ *
4
+ * The probe exists because Windows can leave the process with a stale terminal
5
+ * width — a resize delivered while Ink was still booting, or a console whose
6
+ * reported size disagrees with the window (cmd's screen buffer, ConPTY). See
7
+ * src/lib/terminal-size.ts. These tests drive it with fake tty streams so the
8
+ * parts that must hold on every platform are covered.
9
+ */
10
+ import { EventEmitter } from 'node:events'
11
+ import { PassThrough } from 'node:stream'
12
+ import { createTerminalSizeProbe, extractSizeReports, interpretSizeReport } from '../src/lib/terminal-size.js'
13
+
14
+ let pass = 0, fail = 0
15
+ function ok(condition: boolean, message: string) {
16
+ if (condition) { pass += 1; console.log(` ✓ ${message}`) }
17
+ else { fail += 1; console.error(` ✗ ${message}`) }
18
+ }
19
+
20
+ const delay = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms))
21
+ /** CSI 8 ; n ; n t — the answer to CSI 18 t, given in the terminal's own order. */
22
+ const report = (first: number, second: number) => `\x1b[8;${first};${second}t`
23
+
24
+ function fakeStdin(): NodeJS.ReadStream & { rawCalls: boolean[] } {
25
+ const stdin = new PassThrough() as any
26
+ stdin.isTTY = true
27
+ stdin.isRaw = false
28
+ stdin.rawCalls = []
29
+ stdin.setRawMode = (value: boolean) => { stdin.isRaw = value; stdin.rawCalls.push(value); return stdin }
30
+ return stdin as NodeJS.ReadStream & { rawCalls: boolean[] }
31
+ }
32
+
33
+ function fakeStdout(columns: number, rows: number): NodeJS.WriteStream & { written: string[] } {
34
+ const stdout = new EventEmitter() as any
35
+ stdout.isTTY = true
36
+ stdout.columns = columns // Node keeps these as plain writable data properties
37
+ stdout.rows = rows
38
+ stdout.written = []
39
+ stdout.write = (chunk: string) => { stdout.written.push(String(chunk)); return true }
40
+ return stdout
41
+ }
42
+
43
+ /** Collect what the app would see downstream of the probe. */
44
+ function collector(stream: NodeJS.ReadableStream): { text: () => string } {
45
+ let seen = ''
46
+ stream.on('data', (chunk: Buffer | string) => { seen += String(chunk) })
47
+ return { text: () => seen }
48
+ }
49
+
50
+ function testExtractSizeReports() {
51
+ console.log('\n[SIZE 1] report extraction')
52
+ const one = extractSizeReports(report(30, 113))
53
+ ok(one.reports.length === 1 && one.reports[0][0] === 30 && one.reports[0][1] === 113,
54
+ 'a plain report yields both numbers in the order sent')
55
+ const mixed = extractSizeReports(`ab${report(24, 80)}cd`)
56
+ ok(mixed.rest === 'abcd' && mixed.reports.length === 1, 'report bytes are removed and the rest is kept')
57
+ const two = extractSizeReports(`${report(24, 80)}${report(30, 100)}`)
58
+ ok(two.reports.length === 2 && two.reports[1][1] === 100, 'back-to-back reports both parse')
59
+ ok(extractSizeReports('no report here').reports.length === 0, 'ordinary input yields no reports')
60
+ }
61
+
62
+ function testInterpretSizeReport() {
63
+ console.log('\n[SIZE 2] which number is the width')
64
+ // xterm/Windows Terminal: CSI 8 ; height ; width t — a stale 120-wide console
65
+ // answering for a 113-wide window must correct the width, not swap the axes.
66
+ const documented = interpretSizeReport(30, 113, { columns: 120, rows: 30 })
67
+ ok(documented.columns === 113 && documented.rows === 30, 'the documented height;width order is preferred when it is the closer read')
68
+ // tmux answers width first (measured): 100x30 pane replying "100;30" must not
69
+ // be read as 100 rows tall.
70
+ const swapped = interpretSizeReport(100, 30, { columns: 100, rows: 30 })
71
+ ok(swapped.columns === 100 && swapped.rows === 30, 'a width-first terminal is not turned into 100 rows')
72
+ const tie = interpretSizeReport(24, 80, { columns: 0, rows: 0 })
73
+ ok(tie.columns === 80 && tie.rows === 24, 'an unreadable current size falls back to the documented order')
74
+ }
75
+
76
+ async function testAppliesReportedSize() {
77
+ console.log('\n[SIZE 3] the terminal answer wins over a stale stdout size')
78
+ const stdin = fakeStdin()
79
+ const stdout = fakeStdout(120, 30) // stale, too-wide console size
80
+ const probe = createTerminalSizeProbe(stdin, stdout, { pollMs: 10_000 })
81
+ const seen = collector(probe)
82
+ try {
83
+ ok(stdout.written.join('') === '\x1b[18t', 'the probe asks the terminal with CSI 18 t')
84
+ ok(stdin.rawCalls[0] === true, 'the tty is put in raw mode so the answer is not line-buffered')
85
+ let resized = 0
86
+ stdout.on('resize', () => { resized += 1 })
87
+ stdin.write(report(30, 113))
88
+ await delay(20)
89
+ ok(stdout.columns === 113 && stdout.rows === 30, 'the reported size is mirrored onto stdout')
90
+ ok(resized === 1, 'a resize event is emitted so Ink re-lays out')
91
+ ok(seen.text() === '', 'the report never reaches the app as input')
92
+ } finally { probe.destroy(); stdin.destroy() }
93
+ }
94
+
95
+ async function testSplitReportAcrossChunks() {
96
+ console.log('\n[SIZE 4] a report split across reads')
97
+ const stdin = fakeStdin()
98
+ const stdout = fakeStdout(120, 30)
99
+ const probe = createTerminalSizeProbe(stdin, stdout, { pollMs: 10_000 })
100
+ const seen = collector(probe)
101
+ try {
102
+ stdin.write('\x1b[8;3')
103
+ await delay(5)
104
+ ok(seen.text() === '' && stdout.columns === 120, 'an unfinished report is held, not forwarded or applied')
105
+ stdin.write('0;113t')
106
+ await delay(25)
107
+ ok(stdout.columns === 113 && stdout.rows === 30, 'the finished report applies once the tail arrives')
108
+ ok(seen.text() === '', 'no half-report leaks to the app')
109
+ } finally { probe.destroy(); stdin.destroy() }
110
+ }
111
+
112
+ async function testNormalInputPassesThrough() {
113
+ console.log('\n[SIZE 5] ordinary input is untouched')
114
+ const stdin = fakeStdin()
115
+ const stdout = fakeStdout(120, 30)
116
+ const probe = createTerminalSizeProbe(stdin, stdout, { pollMs: 10_000 })
117
+ const seen = collector(probe)
118
+ try {
119
+ stdin.write('hello \x1b[A\x1b[1;5C\r')
120
+ await delay(30)
121
+ ok(seen.text() === 'hello \x1b[A\x1b[1;5C\r', 'typed text, arrows and Enter pass through unchanged')
122
+ ok(stdout.columns === 120, 'unrelated input does not change the size')
123
+ } finally { probe.destroy(); stdin.destroy() }
124
+ }
125
+
126
+ async function testResizeAsksAgain() {
127
+ console.log('\n[SIZE 6] a real resize re-asks the terminal')
128
+ const stdin = fakeStdin()
129
+ const stdout = fakeStdout(120, 30)
130
+ const probe = createTerminalSizeProbe(stdin, stdout, { pollMs: 10_000 })
131
+ const seen = collector(probe)
132
+ try {
133
+ stdin.write(report(30, 113)); await delay(20)
134
+ ok(stdout.columns === 113, 'first answer applied')
135
+ stdout.written.length = 0
136
+ stdout.emit('resize') // a real window resize
137
+ ok(stdout.written.join('') === '\x1b[18t', 'the probe asks again instead of trusting the stale value')
138
+ stdin.write(report(40, 90)); await delay(20)
139
+ ok(stdout.columns === 90 && stdout.rows === 40, 'the new answer replaces the old one')
140
+ ok(stdout.written.length === 1, 'the probe does not re-ask in a loop off its own resize event')
141
+ } finally { probe.destroy(); stdin.destroy() }
142
+ }
143
+
144
+ async function testPollsNodeSize() {
145
+ console.log('\n[SIZE 7] a size that moved without an event still gets repainted')
146
+ const stdin = fakeStdin()
147
+ const stdout = fakeStdout(120, 30)
148
+ const probe = createTerminalSizeProbe(stdin, stdout, { pollMs: 20 })
149
+ try {
150
+ let resized = 0
151
+ stdout.on('resize', () => { resized += 1 })
152
+ stdout.columns = 90 // the terminal pushed a resize while Ink was booting
153
+ stdout.rows = 24
154
+ await delay(80)
155
+ ok(resized >= 1, 'the periodic re-read nudges Ink once the value moved')
156
+ const settled = resized
157
+ await delay(60)
158
+ ok(resized === settled, 'a size that stopped moving is not nudged again')
159
+ } finally { probe.destroy(); stdin.destroy() }
160
+ }
161
+
162
+ async function testNonsenseIsIgnored() {
163
+ console.log('\n[SIZE 8] unusable answers and non-tty hosts')
164
+ const stdin = fakeStdin()
165
+ const stdout = fakeStdout(120, 30)
166
+ const probe = createTerminalSizeProbe(stdin, stdout, { pollMs: 10_000 })
167
+ try {
168
+ stdin.write(report(0, 0)); await delay(20)
169
+ ok(stdout.columns === 120 && stdout.rows === 30, 'an absurd size is ignored rather than breaking the layout')
170
+ stdin.write(report(900, 5000)); await delay(20)
171
+ ok(stdout.columns === 120, 'an out-of-range width is ignored too')
172
+ } finally { probe.destroy(); stdin.destroy() }
173
+
174
+ const pipe = fakeStdin(); pipe.isTTY = false
175
+ const out = fakeStdout(80, 24)
176
+ ok(createTerminalSizeProbe(pipe, out) === pipe, 'a non-tty stdin is returned untouched')
177
+
178
+ const tty = fakeStdin()
179
+ const pipedOut = fakeStdout(80, 24); pipedOut.isTTY = false
180
+ ok(createTerminalSizeProbe(tty, pipedOut) === tty, 'a non-tty stdout is returned untouched')
181
+ }
182
+
183
+ async function main() {
184
+ testExtractSizeReports()
185
+ testInterpretSizeReport()
186
+ await testAppliesReportedSize()
187
+ await testSplitReportAcrossChunks()
188
+ await testNormalInputPassesThrough()
189
+ await testResizeAsksAgain()
190
+ await testPollsNodeSize()
191
+ await testNonsenseIsIgnored()
192
+ console.log(`\n==== SIZE RESULT: ${pass} passed, ${fail} failed ====\n`)
193
+ process.exit(fail === 0 ? 0 : 1)
194
+ }
195
+
196
+ main().catch(error => { console.error('FATAL', error); process.exit(2) })