omegon 0.7.5 → 0.7.7

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.
@@ -471,17 +471,14 @@ function restartOmegon(): never {
471
471
  "done",
472
472
  // Extra grace period for fd/terminal release
473
473
  "sleep 0.3",
474
- // Hard terminal reset: RIS (Reset to Initial State) clears ALL protocol
475
- // state kitty keyboard protocol, bracketed paste, mouse tracking,
476
- // modifyOtherKeys, SGR, scroll regions, alternate screen, everything.
477
- // This is what `reset` does internally and has worked since the VT100.
478
- "printf '\\033c' 2>/dev/null",
474
+ // Hard terminal reset via /dev/tty avoids stdout buffering that
475
+ // bleeds into the exec'd process. RIS clears all protocol state
476
+ // (kitty keyboard protocol, bracketed paste, mouse tracking, etc.).
477
+ // Do NOT use `reset` here it outputs terminfo init strings to
478
+ // stdout which the new TUI interprets as input (causing stray
479
+ // characters and double renders).
480
+ "printf '\\033c' >/dev/tty 2>/dev/null",
479
481
  "stty sane 2>/dev/null",
480
- // `reset` as belt-and-suspenders — reinitializes terminfo state.
481
- // Some terminals (Kitty) maintain protocol state that RIS alone
482
- // doesn't fully clear; reset queries terminfo and sends the full
483
- // initialization sequence for the current TERM.
484
- "reset 2>/dev/null",
485
482
  // Clean up this script
486
483
  `rm -f "${script}"`,
487
484
  // Replace this shell with new omegon
@@ -492,9 +489,19 @@ function restartOmegon(): never {
492
489
  // (and the user) aren't stuck with raw-mode terminal if something goes wrong.
493
490
  try {
494
491
  // RIS (Reset to Initial State) — the only reliable way to ensure ALL
495
- // terminal protocol state is cleared. Selective escape sequences are
496
- // fragile and miss features we don't know about.
497
- process.stdout.write("\x1bc");
492
+ // terminal protocol state is cleared. Write directly to the TTY fd
493
+ // to bypass pi's TUI layer which intercepts process.stdout and would
494
+ // mangle the escape sequence into visible ANSI garbage.
495
+ const { openSync, writeSync, closeSync } = require("fs") as typeof import("fs");
496
+ let ttyFd = -1;
497
+ try {
498
+ ttyFd = openSync("/dev/tty", "w");
499
+ writeSync(ttyFd, "\x1bc");
500
+ closeSync(ttyFd);
501
+ } catch {
502
+ // Fallback if /dev/tty isn't available (shouldn't happen on macOS/Linux)
503
+ process.stdout.write("\x1bc");
504
+ }
498
505
  // Pause stdin to prevent buffered input from being re-interpreted
499
506
  // after raw mode is disabled (prevents Ctrl+D from closing parent shell).
500
507
  process.stdin.pause();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omegon",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "Omegon — an opinionated distribution of pi (by Mario Zechner) with extensions for lifecycle management, memory, orchestration, and visualization",
5
5
  "bin": {
6
6
  "omegon": "bin/omegon.mjs",