omegon 0.6.14 → 0.6.16
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.
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { execSync } from "node:child_process";
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
9
12
|
|
|
10
13
|
export type DepTier = "core" | "recommended" | "optional";
|
|
11
14
|
|
|
@@ -37,6 +40,29 @@ export interface InstallOption {
|
|
|
37
40
|
cmd: string;
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Ensure well-known tool paths are on PATH before probing.
|
|
45
|
+
*
|
|
46
|
+
* Tools installed by Nix, Cargo, etc. land in directories that may not be
|
|
47
|
+
* in the inherited PATH (e.g. Omegon launched from a shell that predates
|
|
48
|
+
* the install). We patch once at module load so every hasCmd() call sees them.
|
|
49
|
+
*/
|
|
50
|
+
function ensureToolPaths(): void {
|
|
51
|
+
const home = homedir();
|
|
52
|
+
const dirs = [
|
|
53
|
+
"/nix/var/nix/profiles/default/bin",
|
|
54
|
+
join(home, ".nix-profile", "bin"),
|
|
55
|
+
join(home, ".cargo", "bin"),
|
|
56
|
+
];
|
|
57
|
+
const current = process.env.PATH ?? "";
|
|
58
|
+
const parts = current.split(":");
|
|
59
|
+
const missing = dirs.filter(d => existsSync(d) && !parts.includes(d));
|
|
60
|
+
if (missing.length > 0) {
|
|
61
|
+
process.env.PATH = [...missing, current].join(":");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
ensureToolPaths();
|
|
65
|
+
|
|
40
66
|
function hasCmd(cmd: string): boolean {
|
|
41
67
|
try {
|
|
42
68
|
execSync(`which ${cmd}`, { stdio: "ignore" });
|
|
@@ -432,28 +432,66 @@ export default function (pi: ExtensionAPI) {
|
|
|
432
432
|
/**
|
|
433
433
|
* Replace the current Omegon process with a fresh instance.
|
|
434
434
|
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
435
|
+
* Resets terminal state (exits raw mode, alternate screen, mouse capture),
|
|
436
|
+
* then uses shell `exec` to replace the process in-place. This avoids the
|
|
437
|
+
* race between old-process TUI teardown and new-process TUI startup that
|
|
438
|
+
* causes ANSI garbage when using detach+exit.
|
|
438
439
|
*/
|
|
439
440
|
function restartOmegon(): never {
|
|
440
441
|
const { command, argvPrefix } = resolveOmegonSubprocess();
|
|
441
|
-
// Pass through any user-facing args from the original invocation
|
|
442
|
-
// (skip argv[0]=node, argv[1]=omegon.mjs which argvPrefix covers)
|
|
443
442
|
const userArgs = process.argv.slice(2).filter(a =>
|
|
444
|
-
// Strip injected resource flags — the new process injects its own
|
|
445
443
|
!a.startsWith("--extensions-dir=") &&
|
|
446
444
|
!a.startsWith("--themes-dir=") &&
|
|
447
445
|
!a.startsWith("--skills-dir=") &&
|
|
448
|
-
!a.startsWith("--prompts-dir=")
|
|
446
|
+
!a.startsWith("--prompts-dir=") &&
|
|
447
|
+
!a.startsWith("--extension=") && !a.startsWith("--extension ") &&
|
|
448
|
+
!a.startsWith("--skill=") && !a.startsWith("--skill ") &&
|
|
449
|
+
!a.startsWith("--prompt-template=") && !a.startsWith("--prompt-template ") &&
|
|
450
|
+
!a.startsWith("--theme=") && !a.startsWith("--theme ") &&
|
|
451
|
+
!a.startsWith("--no-skills") &&
|
|
452
|
+
!a.startsWith("--no-prompt-templates") &&
|
|
453
|
+
!a.startsWith("--no-themes") &&
|
|
454
|
+
!a.startsWith("--no-extensions")
|
|
449
455
|
);
|
|
450
|
-
|
|
456
|
+
|
|
457
|
+
// Reset terminal to sane state before exec replaces us
|
|
458
|
+
const reset = [
|
|
459
|
+
"\x1b[?1049l", // exit alternate screen buffer
|
|
460
|
+
"\x1b[?1000l", // disable mouse click tracking
|
|
461
|
+
"\x1b[?1002l", // disable mouse drag tracking
|
|
462
|
+
"\x1b[?1006l", // disable SGR mouse mode
|
|
463
|
+
"\x1b[?25h", // show cursor
|
|
464
|
+
"\x1b[0m", // reset attributes
|
|
465
|
+
"\x1bc", // full terminal reset (RIS)
|
|
466
|
+
].join("");
|
|
467
|
+
process.stdout.write(reset);
|
|
468
|
+
|
|
469
|
+
// Exit raw mode if active
|
|
470
|
+
if (process.stdin.isTTY && process.stdin.isRaw) {
|
|
471
|
+
process.stdin.setRawMode(false);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Build the exec command — shell `exec` replaces the process entirely,
|
|
475
|
+
// no orphan child, no race between old and new TUI.
|
|
476
|
+
const parts = [command, ...argvPrefix, ...userArgs].map(shellEscape);
|
|
477
|
+
const child = spawn("sh", ["-c", `exec ${parts.join(" ")}`], {
|
|
451
478
|
stdio: "inherit",
|
|
452
|
-
detached: true,
|
|
453
479
|
env: process.env,
|
|
454
480
|
});
|
|
481
|
+
// If exec fails for some reason, exit when the child does
|
|
482
|
+
child.on("close", (code) => process.exit(code ?? 1));
|
|
483
|
+
// Prevent Node from keeping the event loop alive for other reasons
|
|
455
484
|
child.unref();
|
|
456
|
-
|
|
485
|
+
|
|
486
|
+
// The sh -c exec should have replaced us. If we're still here,
|
|
487
|
+
// just wait for the child.
|
|
488
|
+
return undefined as never;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/** Escape a string for POSIX shell */
|
|
492
|
+
function shellEscape(s: string): string {
|
|
493
|
+
if (/^[a-zA-Z0-9_./:=-]+$/.test(s)) return s;
|
|
494
|
+
return `'${s.replace(/'/g, "'\\''")}'`;
|
|
457
495
|
}
|
|
458
496
|
|
|
459
497
|
/** Run a command, collect stdout+stderr, resolve with exit code. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omegon",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
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",
|