@h-rig/cli 0.0.6-alpha.87 → 0.0.6-alpha.88
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/dist/bin/rig.js +210 -562
- package/dist/src/app-opentui/adapters/common.d.ts +3 -0
- package/dist/src/app-opentui/adapters/common.js +4 -0
- package/dist/src/app-opentui/adapters/family.js +31 -4
- package/dist/src/app-opentui/adapters/pi-attach.d.ts +7 -0
- package/dist/src/app-opentui/adapters/pi-attach.js +527 -473
- package/dist/src/app-opentui/adapters/tasks.js +82 -468
- package/dist/src/app-opentui/bootstrap.js +210 -562
- package/dist/src/app-opentui/index.js +68 -441
- package/dist/src/app-opentui/keymap.js +2 -387
- package/dist/src/app-opentui/pi-host-child.js +31 -4
- package/dist/src/app-opentui/pi-pty-host.d.ts +14 -64
- package/dist/src/app-opentui/pi-pty-host.js +3 -397
- package/dist/src/app-opentui/react/App.js +42 -427
- package/dist/src/app-opentui/react/ChromeHost.js +28 -411
- package/dist/src/app-opentui/react/launch.js +106 -466
- package/dist/src/app-opentui/registry.js +96 -482
- package/dist/src/app-opentui/render/terminal-handoff.d.ts +16 -0
- package/dist/src/app-opentui/render/terminal-handoff.js +14 -0
- package/dist/src/app-opentui/runtime.js +68 -441
- package/dist/src/commands/_operator-view.js +31 -4
- package/dist/src/commands/_pi-frontend.d.ts +25 -0
- package/dist/src/commands/_pi-frontend.js +32 -4
- package/dist/src/commands/run.js +31 -4
- package/dist/src/commands/task.js +31 -4
- package/dist/src/commands.js +31 -4
- package/dist/src/index.js +31 -4
- package/package.json +8 -8
|
@@ -402,7 +402,7 @@ function truncateText(text, width) {
|
|
|
402
402
|
// packages/cli/src/app-opentui/runtime.ts
|
|
403
403
|
import { existsSync as existsSync3 } from "fs";
|
|
404
404
|
import { resolve as resolve3 } from "path";
|
|
405
|
-
import { BoxRenderable as BoxRenderable3, RGBA as
|
|
405
|
+
import { BoxRenderable as BoxRenderable3, RGBA as RGBA7, StyledText as StyledText3, TextRenderable as TextRenderable4, createCliRenderer } from "@opentui/core";
|
|
406
406
|
|
|
407
407
|
// packages/cli/src/app-opentui/focus-manager.ts
|
|
408
408
|
class AppFocusManager {
|
|
@@ -1245,395 +1245,10 @@ function cycleCompletion(value, state, candidates = commandCandidates()) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
|
|
1247
1247
|
// packages/cli/src/app-opentui/pi-pty-host.ts
|
|
1248
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1249
|
-
import { basename as basename2 } from "path";
|
|
1250
|
-
import { RGBA, StyledText, TextAttributes } from "@opentui/core";
|
|
1251
|
-
import { Terminal as XtermTerminal2 } from "@xterm/headless";
|
|
1252
|
-
var MIN_COLS2 = 40;
|
|
1253
|
-
var MIN_ROWS2 = 12;
|
|
1254
|
-
var MAX_ROWS2 = 300;
|
|
1255
|
-
var MAX_SNAPSHOT_LINES2 = 360;
|
|
1256
|
-
var STYLED_SNAPSHOT_MARGIN = 6;
|
|
1257
|
-
var SNAPSHOT_DELAY_MS2 = 120;
|
|
1258
|
-
var fallbackChildScriptPath = fileURLToPath2(new URL("./pi-host-child.ts", import.meta.url));
|
|
1259
|
-
var activeHost2 = null;
|
|
1260
|
-
function clampCols2(cols) {
|
|
1261
|
-
return Math.max(MIN_COLS2, Math.trunc(cols || 100));
|
|
1262
|
-
}
|
|
1263
|
-
function clampRows2(rows) {
|
|
1264
|
-
return Math.max(MIN_ROWS2, Math.min(MAX_ROWS2, Math.trunc(rows || 35)));
|
|
1265
|
-
}
|
|
1266
|
-
var XTERM_COLOR_MODE_INDEXED_16 = 16777216;
|
|
1267
|
-
var XTERM_COLOR_MODE_INDEXED_256 = 33554432;
|
|
1268
|
-
var XTERM_COLOR_MODE_RGB = 50331648;
|
|
1269
|
-
function rgbaFromXtermColor(mode, value) {
|
|
1270
|
-
if (mode === 1 || mode === 2 || mode === XTERM_COLOR_MODE_INDEXED_16 || mode === XTERM_COLOR_MODE_INDEXED_256) {
|
|
1271
|
-
return RGBA.fromIndex(value);
|
|
1272
|
-
}
|
|
1273
|
-
if (mode === 3 || mode === XTERM_COLOR_MODE_RGB) {
|
|
1274
|
-
return RGBA.fromInts(value >> 16 & 255, value >> 8 & 255, value & 255);
|
|
1275
|
-
}
|
|
1276
|
-
return;
|
|
1277
|
-
}
|
|
1278
|
-
function textAttributesFromCell(cell) {
|
|
1279
|
-
let attributes = TextAttributes.NONE;
|
|
1280
|
-
if (cell.isBold())
|
|
1281
|
-
attributes |= TextAttributes.BOLD;
|
|
1282
|
-
if (cell.isDim())
|
|
1283
|
-
attributes |= TextAttributes.DIM;
|
|
1284
|
-
if (cell.isItalic())
|
|
1285
|
-
attributes |= TextAttributes.ITALIC;
|
|
1286
|
-
if (cell.isUnderline())
|
|
1287
|
-
attributes |= TextAttributes.UNDERLINE;
|
|
1288
|
-
if (cell.isBlink())
|
|
1289
|
-
attributes |= TextAttributes.BLINK;
|
|
1290
|
-
if (cell.isInverse())
|
|
1291
|
-
attributes |= TextAttributes.INVERSE;
|
|
1292
|
-
if (cell.isInvisible())
|
|
1293
|
-
attributes |= TextAttributes.HIDDEN;
|
|
1294
|
-
if (cell.isStrikethrough())
|
|
1295
|
-
attributes |= TextAttributes.STRIKETHROUGH;
|
|
1296
|
-
return attributes;
|
|
1297
|
-
}
|
|
1298
|
-
function sameRgba(a, b) {
|
|
1299
|
-
if (!a && !b)
|
|
1300
|
-
return true;
|
|
1301
|
-
return Boolean(a && b && a.equals(b));
|
|
1302
|
-
}
|
|
1303
|
-
function sameStyle(a, b) {
|
|
1304
|
-
return sameRgba(a.fg, b.fg) && sameRgba(a.bg, b.bg) && (a.attributes ?? 0) === (b.attributes ?? 0);
|
|
1305
|
-
}
|
|
1306
|
-
function styleFromCell(cell) {
|
|
1307
|
-
return {
|
|
1308
|
-
fg: rgbaFromXtermColor(cell.getFgColorMode(), cell.getFgColor()),
|
|
1309
|
-
bg: rgbaFromXtermColor(cell.getBgColorMode(), cell.getBgColor()),
|
|
1310
|
-
attributes: textAttributesFromCell(cell)
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
function lineToStyledText(line, cols) {
|
|
1314
|
-
if (!line)
|
|
1315
|
-
return new StyledText([{ __isChunk: true, text: "" }]);
|
|
1316
|
-
const chunks = [];
|
|
1317
|
-
let run = "";
|
|
1318
|
-
let runStyle = null;
|
|
1319
|
-
const flush = () => {
|
|
1320
|
-
if (!run)
|
|
1321
|
-
return;
|
|
1322
|
-
chunks.push({
|
|
1323
|
-
__isChunk: true,
|
|
1324
|
-
text: run,
|
|
1325
|
-
...runStyle?.fg ? { fg: runStyle.fg } : {},
|
|
1326
|
-
...runStyle?.bg ? { bg: runStyle.bg } : {},
|
|
1327
|
-
...(runStyle?.attributes ?? 0) !== 0 ? { attributes: runStyle.attributes } : {}
|
|
1328
|
-
});
|
|
1329
|
-
run = "";
|
|
1330
|
-
};
|
|
1331
|
-
for (let index = 0;index < cols; index += 1) {
|
|
1332
|
-
const cell = line.getCell(index);
|
|
1333
|
-
if (!cell) {
|
|
1334
|
-
if (runStyle !== null)
|
|
1335
|
-
flush();
|
|
1336
|
-
runStyle = null;
|
|
1337
|
-
run += " ";
|
|
1338
|
-
continue;
|
|
1339
|
-
}
|
|
1340
|
-
if (cell.getWidth() === 0)
|
|
1341
|
-
continue;
|
|
1342
|
-
const style = styleFromCell(cell);
|
|
1343
|
-
if (!runStyle || !sameStyle(runStyle, style)) {
|
|
1344
|
-
flush();
|
|
1345
|
-
runStyle = style;
|
|
1346
|
-
}
|
|
1347
|
-
run += cell.getChars() || " ";
|
|
1348
|
-
}
|
|
1349
|
-
flush();
|
|
1350
|
-
return new StyledText(chunks.length > 0 ? chunks : [{ __isChunk: true, text: "" }]);
|
|
1351
|
-
}
|
|
1352
|
-
function childCommandPrefix2() {
|
|
1353
|
-
const execName = basename2(process.execPath).toLowerCase();
|
|
1354
|
-
const currentEntry = process.argv[1];
|
|
1355
|
-
if (execName === "bun" || execName === "bun.exe") {
|
|
1356
|
-
return currentEntry ? [process.execPath, currentEntry, "__opentui-pi-host"] : [process.execPath, fallbackChildScriptPath];
|
|
1357
|
-
}
|
|
1358
|
-
return [process.execPath, "__opentui-pi-host"];
|
|
1359
|
-
}
|
|
1360
|
-
function withEnv2(base) {
|
|
1361
|
-
const env = {};
|
|
1362
|
-
for (const [key, value] of Object.entries(base ?? process.env)) {
|
|
1363
|
-
if (key === "RIG_PLAIN" || key === "RIG_CLI_PLAIN_HELP" || key === "NO_COLOR")
|
|
1364
|
-
continue;
|
|
1365
|
-
if (typeof value === "string")
|
|
1366
|
-
env[key] = value;
|
|
1367
|
-
}
|
|
1368
|
-
return {
|
|
1369
|
-
...env,
|
|
1370
|
-
TERM: "xterm-256color",
|
|
1371
|
-
COLORTERM: "truecolor",
|
|
1372
|
-
FORCE_COLOR: env.FORCE_COLOR ?? "1",
|
|
1373
|
-
RIG_OPENTUI_PI_HOST: "1"
|
|
1374
|
-
};
|
|
1375
|
-
}
|
|
1376
1248
|
function getActivePiHost() {
|
|
1377
|
-
return
|
|
1378
|
-
}
|
|
1379
|
-
function stopActivePiHost(reason = "detach") {
|
|
1380
|
-
activeHost2?.dispose(reason);
|
|
1381
|
-
activeHost2 = null;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
class PiPtyHost {
|
|
1385
|
-
runId;
|
|
1386
|
-
projectRoot;
|
|
1387
|
-
onSnapshot;
|
|
1388
|
-
onExit;
|
|
1389
|
-
onError;
|
|
1390
|
-
terminal;
|
|
1391
|
-
disposables = [];
|
|
1392
|
-
decoder = new TextDecoder("utf-8");
|
|
1393
|
-
proc = null;
|
|
1394
|
-
pty = null;
|
|
1395
|
-
status = "starting";
|
|
1396
|
-
cols;
|
|
1397
|
-
rows;
|
|
1398
|
-
message = "starting bundled Pi";
|
|
1399
|
-
lastResizeError = null;
|
|
1400
|
-
exitCode;
|
|
1401
|
-
signal;
|
|
1402
|
-
notifyTimer = null;
|
|
1403
|
-
lastStreamKey = "";
|
|
1404
|
-
_disposed = false;
|
|
1405
|
-
constructor(options) {
|
|
1406
|
-
this.runId = options.runId;
|
|
1407
|
-
this.projectRoot = options.projectRoot;
|
|
1408
|
-
this.cols = clampCols2(options.cols);
|
|
1409
|
-
this.rows = clampRows2(options.rows);
|
|
1410
|
-
this.onSnapshot = options.onSnapshot;
|
|
1411
|
-
this.onExit = options.onExit;
|
|
1412
|
-
this.onError = options.onError;
|
|
1413
|
-
this.terminal = new XtermTerminal2({
|
|
1414
|
-
allowProposedApi: true,
|
|
1415
|
-
cols: this.cols,
|
|
1416
|
-
rows: this.rows,
|
|
1417
|
-
scrollback: 1000
|
|
1418
|
-
});
|
|
1419
|
-
this.registerTerminalResponders();
|
|
1420
|
-
this.disposables.push(this.terminal.onWriteParsed(() => {
|
|
1421
|
-
if (this._disposed)
|
|
1422
|
-
return;
|
|
1423
|
-
const snapshot = this.createSnapshot();
|
|
1424
|
-
const key = snapshot.lines.join(`
|
|
1425
|
-
`);
|
|
1426
|
-
if (key === this.lastStreamKey)
|
|
1427
|
-
return;
|
|
1428
|
-
this.lastStreamKey = key;
|
|
1429
|
-
this.onSnapshot?.(snapshot);
|
|
1430
|
-
}));
|
|
1431
|
-
}
|
|
1432
|
-
get disposed() {
|
|
1433
|
-
return this._disposed;
|
|
1434
|
-
}
|
|
1435
|
-
get snapshot() {
|
|
1436
|
-
return this.createSnapshot();
|
|
1437
|
-
}
|
|
1438
|
-
async start() {
|
|
1439
|
-
if (this._disposed)
|
|
1440
|
-
throw new Error("Pi PTY host is disposed.");
|
|
1441
|
-
if (typeof Bun.Terminal !== "function") {
|
|
1442
|
-
throw new Error("Bun native PTY is unavailable in this runtime. Pi host requires Bun.Terminal.");
|
|
1443
|
-
}
|
|
1444
|
-
const spawnOptions = {
|
|
1445
|
-
cwd: this.projectRoot,
|
|
1446
|
-
env: withEnv2(process.env),
|
|
1447
|
-
terminal: {
|
|
1448
|
-
cols: this.cols,
|
|
1449
|
-
rows: this.rows,
|
|
1450
|
-
name: "xterm-256color",
|
|
1451
|
-
data: (_terminal, data) => this.handlePtyData(data)
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
const proc = Bun.spawn([
|
|
1455
|
-
...childCommandPrefix2(),
|
|
1456
|
-
"--run-id",
|
|
1457
|
-
this.runId,
|
|
1458
|
-
"--project-root",
|
|
1459
|
-
this.projectRoot
|
|
1460
|
-
], spawnOptions);
|
|
1461
|
-
if (!proc.terminal)
|
|
1462
|
-
throw new Error("Bun did not attach a terminal to the bundled Pi child process.");
|
|
1463
|
-
this.proc = proc;
|
|
1464
|
-
this.pty = proc.terminal;
|
|
1465
|
-
this.status = "running";
|
|
1466
|
-
this.message = "bundled Pi running inside this app";
|
|
1467
|
-
this.emitSnapshotSoon(0);
|
|
1468
|
-
proc.exited.then((exitCode) => {
|
|
1469
|
-
if (this._disposed)
|
|
1470
|
-
return;
|
|
1471
|
-
this.status = exitCode === 0 ? "exited" : "failed";
|
|
1472
|
-
this.exitCode = exitCode;
|
|
1473
|
-
this.signal = null;
|
|
1474
|
-
this.message = exitCode === 0 ? "bundled Pi exited" : `bundled Pi exited with code ${exitCode}`;
|
|
1475
|
-
const snapshot = this.createSnapshot();
|
|
1476
|
-
this.onSnapshot?.(snapshot);
|
|
1477
|
-
this.onExit?.(snapshot);
|
|
1478
|
-
if (activeHost2 === this)
|
|
1479
|
-
activeHost2 = null;
|
|
1480
|
-
this.dispose("exit", { kill: false, notify: false });
|
|
1481
|
-
}).catch((error) => {
|
|
1482
|
-
if (this._disposed)
|
|
1483
|
-
return;
|
|
1484
|
-
this.status = "failed";
|
|
1485
|
-
this.message = error instanceof Error ? error.message : String(error);
|
|
1486
|
-
const snapshot = this.createSnapshot();
|
|
1487
|
-
this.onSnapshot?.(snapshot);
|
|
1488
|
-
this.onError?.(error, snapshot);
|
|
1489
|
-
if (activeHost2 === this)
|
|
1490
|
-
activeHost2 = null;
|
|
1491
|
-
this.dispose("error", { kill: false, notify: false });
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
write(data) {
|
|
1495
|
-
if (this._disposed || !this.pty)
|
|
1496
|
-
return;
|
|
1497
|
-
try {
|
|
1498
|
-
this.pty.write(data);
|
|
1499
|
-
} catch (error) {
|
|
1500
|
-
this.status = "failed";
|
|
1501
|
-
this.message = error instanceof Error ? error.message : String(error);
|
|
1502
|
-
const snapshot = this.createSnapshot();
|
|
1503
|
-
this.onSnapshot?.(snapshot);
|
|
1504
|
-
this.onError?.(error, snapshot);
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
resize(cols, rows) {
|
|
1508
|
-
const nextCols = clampCols2(cols);
|
|
1509
|
-
const nextRows = clampRows2(rows);
|
|
1510
|
-
if (nextCols === this.cols && nextRows === this.rows)
|
|
1511
|
-
return;
|
|
1512
|
-
this.cols = nextCols;
|
|
1513
|
-
this.rows = nextRows;
|
|
1514
|
-
this.terminal.resize(nextCols, nextRows);
|
|
1515
|
-
try {
|
|
1516
|
-
this.pty?.resize(nextCols, nextRows);
|
|
1517
|
-
this.lastResizeError = null;
|
|
1518
|
-
} catch (error) {
|
|
1519
|
-
this.lastResizeError = error instanceof Error ? error.message : String(error);
|
|
1520
|
-
}
|
|
1521
|
-
this.emitSnapshotSoon(0);
|
|
1522
|
-
}
|
|
1523
|
-
detach() {
|
|
1524
|
-
this.dispose("detach");
|
|
1525
|
-
return this.createSnapshot("detached from bundled Pi");
|
|
1526
|
-
}
|
|
1527
|
-
dispose(reason = "dispose", options = {}) {
|
|
1528
|
-
if (this._disposed)
|
|
1529
|
-
return;
|
|
1530
|
-
this._disposed = true;
|
|
1531
|
-
if (this.notifyTimer)
|
|
1532
|
-
clearTimeout(this.notifyTimer);
|
|
1533
|
-
this.notifyTimer = null;
|
|
1534
|
-
for (const disposable of this.disposables.splice(0)) {
|
|
1535
|
-
try {
|
|
1536
|
-
disposable.dispose();
|
|
1537
|
-
} catch {}
|
|
1538
|
-
}
|
|
1539
|
-
if (options.kill !== false) {
|
|
1540
|
-
try {
|
|
1541
|
-
this.proc?.kill("SIGTERM");
|
|
1542
|
-
} catch {}
|
|
1543
|
-
}
|
|
1544
|
-
try {
|
|
1545
|
-
this.pty?.close();
|
|
1546
|
-
} catch {}
|
|
1547
|
-
try {
|
|
1548
|
-
this.terminal.dispose();
|
|
1549
|
-
} catch {}
|
|
1550
|
-
if (activeHost2 === this)
|
|
1551
|
-
activeHost2 = null;
|
|
1552
|
-
if (options.notify) {
|
|
1553
|
-
this.message = reason;
|
|
1554
|
-
this.onSnapshot?.(this.createSnapshot(reason));
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
handlePtyData(data) {
|
|
1558
|
-
if (this._disposed)
|
|
1559
|
-
return;
|
|
1560
|
-
const text = this.decoder.decode(data, { stream: true });
|
|
1561
|
-
this.respondToRawTerminalQueries(text);
|
|
1562
|
-
this.terminal.write(data);
|
|
1563
|
-
}
|
|
1564
|
-
emitSnapshotSoon(delayMs = SNAPSHOT_DELAY_MS2) {
|
|
1565
|
-
if (this._disposed || this.notifyTimer)
|
|
1566
|
-
return;
|
|
1567
|
-
this.notifyTimer = setTimeout(() => {
|
|
1568
|
-
this.notifyTimer = null;
|
|
1569
|
-
if (this._disposed)
|
|
1570
|
-
return;
|
|
1571
|
-
this.onSnapshot?.(this.createSnapshot());
|
|
1572
|
-
}, delayMs);
|
|
1573
|
-
}
|
|
1574
|
-
createSnapshot(message = this.message) {
|
|
1575
|
-
const buffer = this.terminal.buffer.active;
|
|
1576
|
-
const end = buffer.length;
|
|
1577
|
-
const start = Math.max(0, end - MAX_SNAPSHOT_LINES2);
|
|
1578
|
-
const styledStart = Math.max(start, end - this.rows - STYLED_SNAPSHOT_MARGIN);
|
|
1579
|
-
const lines = [];
|
|
1580
|
-
const styledLines = [];
|
|
1581
|
-
for (let row = start;row < end; row += 1) {
|
|
1582
|
-
const line = buffer.getLine(row);
|
|
1583
|
-
lines.push((line?.translateToString(false) ?? "").slice(0, this.cols));
|
|
1584
|
-
if (row >= styledStart)
|
|
1585
|
-
styledLines[lines.length - 1] = lineToStyledText(line, this.cols);
|
|
1586
|
-
}
|
|
1587
|
-
while (lines.length < this.rows) {
|
|
1588
|
-
lines.push("");
|
|
1589
|
-
styledLines[lines.length - 1] = new StyledText([{ __isChunk: true, text: "" }]);
|
|
1590
|
-
}
|
|
1591
|
-
const resolvedMessage = this.lastResizeError ? `resize degraded: ${this.lastResizeError}` : message;
|
|
1592
|
-
return {
|
|
1593
|
-
runId: this.runId,
|
|
1594
|
-
status: this.status,
|
|
1595
|
-
cols: this.cols,
|
|
1596
|
-
rows: this.rows,
|
|
1597
|
-
lines,
|
|
1598
|
-
styledLines,
|
|
1599
|
-
message: resolvedMessage,
|
|
1600
|
-
...this.lastResizeError ? { resizeError: this.lastResizeError } : {},
|
|
1601
|
-
...this.exitCode !== undefined ? { exitCode: this.exitCode } : {},
|
|
1602
|
-
...this.signal !== undefined ? { signal: this.signal } : {}
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
registerTerminalResponders() {
|
|
1606
|
-
this.disposables.push(this.terminal.parser.registerCsiHandler({ final: "c" }, (params) => {
|
|
1607
|
-
if (params.length === 0 || params[0] === 0)
|
|
1608
|
-
this.write("\x1B[?62;22c");
|
|
1609
|
-
return false;
|
|
1610
|
-
}));
|
|
1611
|
-
this.disposables.push(this.terminal.parser.registerCsiHandler({ prefix: ">", final: "c" }, (params) => {
|
|
1612
|
-
if (params.length === 0 || params[0] === 0)
|
|
1613
|
-
this.write("\x1B[>0;0;0c");
|
|
1614
|
-
return false;
|
|
1615
|
-
}));
|
|
1616
|
-
this.disposables.push(this.terminal.parser.registerCsiHandler({ final: "n" }, (params) => {
|
|
1617
|
-
if (params[0] === 5) {
|
|
1618
|
-
this.write("\x1B[0n");
|
|
1619
|
-
} else if (params[0] === 6) {
|
|
1620
|
-
const row = this.terminal.buffer.active.cursorY + 1;
|
|
1621
|
-
const col = this.terminal.buffer.active.cursorX + 1;
|
|
1622
|
-
this.write(`\x1B[${row};${col}R`);
|
|
1623
|
-
}
|
|
1624
|
-
return false;
|
|
1625
|
-
}));
|
|
1626
|
-
}
|
|
1627
|
-
respondToRawTerminalQueries(text) {
|
|
1628
|
-
if (!text)
|
|
1629
|
-
return;
|
|
1630
|
-
const decrqm = /\x1b\[\?(\d+)\$p/g;
|
|
1631
|
-
let match;
|
|
1632
|
-
while ((match = decrqm.exec(text)) !== null) {
|
|
1633
|
-
this.write(`\x1B[?${match[1]};2$y`);
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1249
|
+
return null;
|
|
1636
1250
|
}
|
|
1251
|
+
function stopActivePiHost(_reason) {}
|
|
1637
1252
|
|
|
1638
1253
|
// packages/cli/src/app-opentui/keymap.ts
|
|
1639
1254
|
var autocompleteState;
|
|
@@ -2235,7 +1850,7 @@ import {
|
|
|
2235
1850
|
dim as otuiDim,
|
|
2236
1851
|
fg as otuiFg,
|
|
2237
1852
|
t,
|
|
2238
|
-
TextAttributes
|
|
1853
|
+
TextAttributes
|
|
2239
1854
|
} from "@opentui/core";
|
|
2240
1855
|
var RIG_UI = {
|
|
2241
1856
|
bg: "#070809",
|
|
@@ -2298,7 +1913,7 @@ function statusColor(status) {
|
|
|
2298
1913
|
}
|
|
2299
1914
|
|
|
2300
1915
|
// packages/cli/src/app-opentui/drone.ts
|
|
2301
|
-
import { RGBA
|
|
1916
|
+
import { RGBA, StyledText, TextAttributes as TextAttributes2 } from "@opentui/core";
|
|
2302
1917
|
var MINI_DRONE = [
|
|
2303
1918
|
"(!!!) (!!!)",
|
|
2304
1919
|
" \\%==%/ ",
|
|
@@ -2314,13 +1929,13 @@ var LEAD_MARK = [
|
|
|
2314
1929
|
var BLADE_FRAMES = ["---", "\\\\\\", "|||", "///"];
|
|
2315
1930
|
var EYE_FRAMES = ["o", "@", "\u2022", "."];
|
|
2316
1931
|
var COLOR = {
|
|
2317
|
-
body:
|
|
2318
|
-
mini:
|
|
2319
|
-
rotor:
|
|
2320
|
-
path:
|
|
2321
|
-
eye:
|
|
2322
|
-
dim:
|
|
2323
|
-
ink:
|
|
1932
|
+
body: RGBA.fromHex(RIG_UI.lime),
|
|
1933
|
+
mini: RGBA.fromHex(RIG_UI.limeDim),
|
|
1934
|
+
rotor: RGBA.fromHex(RIG_UI.cyan),
|
|
1935
|
+
path: RGBA.fromHex(RIG_UI.cyan),
|
|
1936
|
+
eye: RGBA.fromHex(RIG_UI.ink),
|
|
1937
|
+
dim: RGBA.fromHex(RIG_UI.ink4),
|
|
1938
|
+
ink: RGBA.fromHex(RIG_UI.ink2)
|
|
2324
1939
|
};
|
|
2325
1940
|
function bladeForTick(tick, phase = 0) {
|
|
2326
1941
|
return BLADE_FRAMES[(Math.floor(tick / 3) + phase) % BLADE_FRAMES.length];
|
|
@@ -2330,12 +1945,12 @@ function eyeForTick(tick, phase = 0) {
|
|
|
2330
1945
|
return pulse > 0.55 ? EYE_FRAMES[1] : pulse > 0.1 ? EYE_FRAMES[0] : pulse > -0.45 ? EYE_FRAMES[2] : EYE_FRAMES[3];
|
|
2331
1946
|
}
|
|
2332
1947
|
function chunk(text, fg, bold = false, dim = false) {
|
|
2333
|
-
let attributes =
|
|
1948
|
+
let attributes = TextAttributes2.NONE;
|
|
2334
1949
|
if (bold)
|
|
2335
|
-
attributes |=
|
|
1950
|
+
attributes |= TextAttributes2.BOLD;
|
|
2336
1951
|
if (dim)
|
|
2337
|
-
attributes |=
|
|
2338
|
-
return { __isChunk: true, text, fg, ...attributes !==
|
|
1952
|
+
attributes |= TextAttributes2.DIM;
|
|
1953
|
+
return { __isChunk: true, text, fg, ...attributes !== TextAttributes2.NONE ? { attributes } : {} };
|
|
2339
1954
|
}
|
|
2340
1955
|
function styledLine(text, colorFor) {
|
|
2341
1956
|
const chunks = [];
|
|
@@ -2356,7 +1971,7 @@ function styledLine(text, colorFor) {
|
|
|
2356
1971
|
run += char;
|
|
2357
1972
|
}
|
|
2358
1973
|
flush();
|
|
2359
|
-
return new
|
|
1974
|
+
return new StyledText(chunks.length > 0 ? chunks : [chunk("", COLOR.ink)]);
|
|
2360
1975
|
}
|
|
2361
1976
|
function droneColor(char) {
|
|
2362
1977
|
if (char === "?" || char === "o" || char === "@" || char === "\u2022")
|
|
@@ -2666,7 +2281,7 @@ function reduceAppEvent(state, event) {
|
|
|
2666
2281
|
}
|
|
2667
2282
|
|
|
2668
2283
|
// packages/cli/src/app-opentui/render/graphics.ts
|
|
2669
|
-
import { FrameBufferRenderable, RGBA as
|
|
2284
|
+
import { FrameBufferRenderable, RGBA as RGBA2 } from "@opentui/core";
|
|
2670
2285
|
|
|
2671
2286
|
// packages/cli/src/app-opentui/render/ascii-fleet.ts
|
|
2672
2287
|
var LEAD_DRONE = [
|
|
@@ -2810,13 +2425,13 @@ var GLOW_FALLOFF_EXP_ASCII = 2.2;
|
|
|
2810
2425
|
// packages/cli/src/app-opentui/render/graphics.ts
|
|
2811
2426
|
var BRAILLE_SAMPLES_X = 2;
|
|
2812
2427
|
var BRAILLE_SAMPLES_Y = 4;
|
|
2813
|
-
var TRANSPARENT =
|
|
2814
|
-
var BACKDROP =
|
|
2815
|
-
var PANEL_BG =
|
|
2816
|
-
var PANEL_HEADER_BG =
|
|
2817
|
-
var PANEL_LINE =
|
|
2818
|
-
var PANEL_LINE_DIM =
|
|
2819
|
-
var PANEL_TEXT_DIM =
|
|
2428
|
+
var TRANSPARENT = RGBA2.fromValues(0, 0, 0, 0);
|
|
2429
|
+
var BACKDROP = RGBA2.fromHex(RIG_UI.bg);
|
|
2430
|
+
var PANEL_BG = RGBA2.fromInts(16, 17, 21, 184);
|
|
2431
|
+
var PANEL_HEADER_BG = RGBA2.fromInts(16, 17, 21, 188);
|
|
2432
|
+
var PANEL_LINE = RGBA2.fromInts(255, 255, 255, 20);
|
|
2433
|
+
var PANEL_LINE_DIM = RGBA2.fromInts(255, 255, 255, 8);
|
|
2434
|
+
var PANEL_TEXT_DIM = RGBA2.fromInts(108, 110, 121, 255);
|
|
2820
2435
|
var AC_RGB = [204, 255, 77];
|
|
2821
2436
|
var C2_RGB = [86, 216, 255];
|
|
2822
2437
|
var MG_RGB = [255, 121, 176];
|
|
@@ -2921,7 +2536,7 @@ function paletteColor(ac, c2, mg, ink) {
|
|
|
2921
2536
|
const b = (AC_RGB[2] * ac + C2_RGB[2] * c2 + MG_RGB[2] * mg + INK_RGB[2] * ink) / total;
|
|
2922
2537
|
const intensity = Math.min(1, total / 4);
|
|
2923
2538
|
const lift = 0.34 + intensity * 0.66;
|
|
2924
|
-
return
|
|
2539
|
+
return RGBA2.fromInts(Math.round(r * lift), Math.round(g * lift), Math.round(b * lift), 255);
|
|
2925
2540
|
}
|
|
2926
2541
|
function clearCanvas(canvas) {
|
|
2927
2542
|
canvas.ac.fill(0);
|
|
@@ -3276,8 +2891,8 @@ function staticFleetTick(scene) {
|
|
|
3276
2891
|
}
|
|
3277
2892
|
function withAlpha(hex, alpha) {
|
|
3278
2893
|
const a = Math.max(0, Math.min(255, Math.round(alpha * 255)));
|
|
3279
|
-
const [r, g, b] =
|
|
3280
|
-
return
|
|
2894
|
+
const [r, g, b] = RGBA2.fromHex(hex).toInts();
|
|
2895
|
+
return RGBA2.fromInts(r, g, b, a);
|
|
3281
2896
|
}
|
|
3282
2897
|
function asciiFleetColor(char, row, alpha) {
|
|
3283
2898
|
if (char === "@" || char === "$" || char === "o")
|
|
@@ -3285,7 +2900,7 @@ function asciiFleetColor(char, row, alpha) {
|
|
|
3285
2900
|
if (char === "%" || char === "!" || char === "/" || char === "\\" || char === "|")
|
|
3286
2901
|
return withAlpha(RIG_UI.cyan, alpha);
|
|
3287
2902
|
if (char === "." || char === "'" || char === "_" || row < 3 || row > FLEET_GRID_HEIGHT - 4) {
|
|
3288
|
-
return
|
|
2903
|
+
return RGBA2.fromInts(108, 110, 121, Math.min(170, Math.max(0, Math.min(255, Math.round(alpha * 255)))));
|
|
3289
2904
|
}
|
|
3290
2905
|
return withAlpha(RIG_UI.limeDim, alpha);
|
|
3291
2906
|
}
|
|
@@ -3398,7 +3013,7 @@ function sparklineString(values, width) {
|
|
|
3398
3013
|
}
|
|
3399
3014
|
|
|
3400
3015
|
// packages/cli/src/app-opentui/render/text.ts
|
|
3401
|
-
import { RGBA as
|
|
3016
|
+
import { RGBA as RGBA3, TextAttributes as TextAttributes3, TextRenderable } from "@opentui/core";
|
|
3402
3017
|
|
|
3403
3018
|
// packages/cli/src/app-opentui/render/hover.ts
|
|
3404
3019
|
var hoveredId;
|
|
@@ -3425,8 +3040,8 @@ function subscribeHover(listener) {
|
|
|
3425
3040
|
}
|
|
3426
3041
|
|
|
3427
3042
|
// packages/cli/src/app-opentui/render/text.ts
|
|
3428
|
-
var TRANSPARENT2 =
|
|
3429
|
-
var HOVER_BG =
|
|
3043
|
+
var TRANSPARENT2 = RGBA3.fromInts(0, 0, 0, 0);
|
|
3044
|
+
var HOVER_BG = RGBA3.fromHex(RIG_UI.hover);
|
|
3430
3045
|
function lineIsClickable(line2) {
|
|
3431
3046
|
return line2?.selectable !== undefined || line2?.selectableIndex !== undefined;
|
|
3432
3047
|
}
|
|
@@ -3435,7 +3050,7 @@ function lineSelectableId(line2) {
|
|
|
3435
3050
|
}
|
|
3436
3051
|
function lineBackground(line2) {
|
|
3437
3052
|
if (line2?.bg)
|
|
3438
|
-
return
|
|
3053
|
+
return RGBA3.fromHex(line2.bg);
|
|
3439
3054
|
const id = lineSelectableId(line2);
|
|
3440
3055
|
if (id !== undefined && isHovered(id))
|
|
3441
3056
|
return HOVER_BG;
|
|
@@ -3504,7 +3119,7 @@ function applyTextLine(renderable, line2, top, left, width) {
|
|
|
3504
3119
|
renderable.content = line2?.styledText ?? line2?.text ?? "";
|
|
3505
3120
|
renderable.fg = line2?.fg ?? RIG_UI.ink2;
|
|
3506
3121
|
renderable.bg = lineBackground(line2);
|
|
3507
|
-
renderable.attributes = line2?.bold ?
|
|
3122
|
+
renderable.attributes = line2?.bold ? TextAttributes3.BOLD : line2?.dim ? TextAttributes3.DIM : 0;
|
|
3508
3123
|
}
|
|
3509
3124
|
function applyFlowTextLine(renderable, line2, width) {
|
|
3510
3125
|
renderable.setRigSceneLine?.(line2);
|
|
@@ -3514,7 +3129,7 @@ function applyFlowTextLine(renderable, line2, width) {
|
|
|
3514
3129
|
renderable.content = line2?.styledText ?? line2?.text ?? "";
|
|
3515
3130
|
renderable.fg = line2?.fg ?? RIG_UI.ink2;
|
|
3516
3131
|
renderable.bg = lineBackground(line2);
|
|
3517
|
-
renderable.attributes = line2?.bold ?
|
|
3132
|
+
renderable.attributes = line2?.bold ? TextAttributes3.BOLD : line2?.dim ? TextAttributes3.DIM : 0;
|
|
3518
3133
|
}
|
|
3519
3134
|
function clearTextLines(renderables, from = 0) {
|
|
3520
3135
|
for (let index = from;index < renderables.length; index += 1) {
|
|
@@ -3528,9 +3143,20 @@ function clearTextLines(renderables, from = 0) {
|
|
|
3528
3143
|
}
|
|
3529
3144
|
}
|
|
3530
3145
|
|
|
3146
|
+
// packages/cli/src/app-opentui/render/terminal-handoff.ts
|
|
3147
|
+
function resumeRendererClean(renderer) {
|
|
3148
|
+
try {
|
|
3149
|
+
renderer.pendingSuspendedTerminalSetup = true;
|
|
3150
|
+
} catch {}
|
|
3151
|
+
renderer.resume();
|
|
3152
|
+
try {
|
|
3153
|
+
renderer.requestRender?.();
|
|
3154
|
+
} catch {}
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3531
3157
|
// packages/cli/src/app-opentui/render/panels.ts
|
|
3532
|
-
import { RGBA as
|
|
3533
|
-
var TRANSPARENT3 =
|
|
3158
|
+
import { RGBA as RGBA4, ScrollBoxRenderable } from "@opentui/core";
|
|
3159
|
+
var TRANSPARENT3 = RGBA4.fromInts(0, 0, 0, 0);
|
|
3534
3160
|
var MAX_PANEL_LINES = 420;
|
|
3535
3161
|
var PANEL_OPAQUE_ALPHA = 255;
|
|
3536
3162
|
var PANEL_BORDER = hexToRgba(RIG_UI.border, 255);
|
|
@@ -3539,8 +3165,8 @@ function hexToRgba(hex, alpha) {
|
|
|
3539
3165
|
const full = clean.length === 3 ? clean.split("").map((part) => `${part}${part}`).join("") : clean;
|
|
3540
3166
|
const value = Number.parseInt(full, 16);
|
|
3541
3167
|
if (!Number.isFinite(value))
|
|
3542
|
-
return
|
|
3543
|
-
return
|
|
3168
|
+
return RGBA4.fromInts(14, 15, 17, alpha);
|
|
3169
|
+
return RGBA4.fromInts(value >> 16 & 255, value >> 8 & 255, value & 255, alpha);
|
|
3544
3170
|
}
|
|
3545
3171
|
function panelBackground(panel) {
|
|
3546
3172
|
return hexToRgba(panel.backgroundColor ?? RIG_UI.panel, PANEL_OPAQUE_ALPHA);
|
|
@@ -3655,9 +3281,9 @@ function applyScrollPanels(panels, layout, scenePanels) {
|
|
|
3655
3281
|
}
|
|
3656
3282
|
|
|
3657
3283
|
// packages/cli/src/app-opentui/render/type-bar.ts
|
|
3658
|
-
import { BoxRenderable, InputRenderable, InputRenderableEvents, RGBA as
|
|
3659
|
-
var TYPEBAR_BG =
|
|
3660
|
-
var TYPEBAR_BORDER =
|
|
3284
|
+
import { BoxRenderable, InputRenderable, InputRenderableEvents, RGBA as RGBA5, StyledText as StyledText2, TextRenderable as TextRenderable2 } from "@opentui/core";
|
|
3285
|
+
var TYPEBAR_BG = RGBA5.fromInts(20, 25, 14, 224);
|
|
3286
|
+
var TYPEBAR_BORDER = RGBA5.fromInts(204, 255, 77, 92);
|
|
3661
3287
|
function createTypeBar(renderer) {
|
|
3662
3288
|
const background = new BoxRenderable(renderer, {
|
|
3663
3289
|
id: "typebar-card",
|
|
@@ -3805,7 +3431,7 @@ function formatFooter(footer, width) {
|
|
|
3805
3431
|
chunks.push(cell.style(text));
|
|
3806
3432
|
used += visibleWidth(text);
|
|
3807
3433
|
});
|
|
3808
|
-
return new
|
|
3434
|
+
return new StyledText2(chunks);
|
|
3809
3435
|
}
|
|
3810
3436
|
|
|
3811
3437
|
// packages/cli/src/app-opentui/render/native-host.ts
|
|
@@ -3813,7 +3439,7 @@ import {
|
|
|
3813
3439
|
BoxRenderable as BoxRenderable2,
|
|
3814
3440
|
CodeRenderable,
|
|
3815
3441
|
DiffRenderable,
|
|
3816
|
-
RGBA as
|
|
3442
|
+
RGBA as RGBA6,
|
|
3817
3443
|
ScrollBoxRenderable as ScrollBoxRenderable2,
|
|
3818
3444
|
SyntaxStyle,
|
|
3819
3445
|
TextRenderable as TextRenderable3,
|
|
@@ -3824,19 +3450,19 @@ function rigSyntaxStyle() {
|
|
|
3824
3450
|
if (syntaxStyle)
|
|
3825
3451
|
return syntaxStyle;
|
|
3826
3452
|
syntaxStyle = SyntaxStyle.fromStyles({
|
|
3827
|
-
keyword: { fg:
|
|
3828
|
-
string: { fg:
|
|
3829
|
-
number: { fg:
|
|
3830
|
-
comment: { fg:
|
|
3831
|
-
function: { fg:
|
|
3832
|
-
type: { fg:
|
|
3833
|
-
constant: { fg:
|
|
3834
|
-
default: { fg:
|
|
3453
|
+
keyword: { fg: RGBA6.fromHex(RIG_UI.magenta), bold: true },
|
|
3454
|
+
string: { fg: RGBA6.fromHex(RIG_UI.lime) },
|
|
3455
|
+
number: { fg: RGBA6.fromHex(RIG_UI.cyan) },
|
|
3456
|
+
comment: { fg: RGBA6.fromHex(RIG_UI.ink4), italic: true },
|
|
3457
|
+
function: { fg: RGBA6.fromHex(RIG_UI.cyan) },
|
|
3458
|
+
type: { fg: RGBA6.fromHex(RIG_UI.limeDim) },
|
|
3459
|
+
constant: { fg: RGBA6.fromHex(RIG_UI.yellow) },
|
|
3460
|
+
default: { fg: RGBA6.fromHex(RIG_UI.ink2) }
|
|
3835
3461
|
});
|
|
3836
3462
|
return syntaxStyle;
|
|
3837
3463
|
}
|
|
3838
3464
|
function tableContent(rows) {
|
|
3839
|
-
return rows.map((row, rowIndex) => row.map((cell) => [{ __isChunk: true, text: cell, fg:
|
|
3465
|
+
return rows.map((row, rowIndex) => row.map((cell) => [{ __isChunk: true, text: cell, fg: RGBA6.fromHex(rowIndex === 0 ? RIG_UI.ink3 : RIG_UI.ink2) }]));
|
|
3840
3466
|
}
|
|
3841
3467
|
function createNativeHost(renderer) {
|
|
3842
3468
|
try {
|
|
@@ -4326,7 +3952,7 @@ function renderMainScene(state, layout) {
|
|
|
4326
3952
|
var MAX_SCENE_LINES = 200;
|
|
4327
3953
|
var MAX_SCENE_PANELS = 5;
|
|
4328
3954
|
var ANIMATION_SLOWDOWN = 1;
|
|
4329
|
-
var PRELOADER_BACKDROP =
|
|
3955
|
+
var PRELOADER_BACKDROP = RGBA7.fromHex(RIG_UI.bg);
|
|
4330
3956
|
function inboxPendingCount(state) {
|
|
4331
3957
|
const inbox = state.data.inbox;
|
|
4332
3958
|
if (!inbox || typeof inbox !== "object" || Array.isArray(inbox))
|
|
@@ -4531,7 +4157,7 @@ function buildNavStrip(state) {
|
|
|
4531
4157
|
chunks.push(otuiBold(styles.yellow(String(badgeCount))));
|
|
4532
4158
|
}
|
|
4533
4159
|
});
|
|
4534
|
-
return new
|
|
4160
|
+
return new StyledText3(chunks);
|
|
4535
4161
|
}
|
|
4536
4162
|
function requestRender(renderer) {
|
|
4537
4163
|
renderer.requestRender?.();
|
|
@@ -4729,7 +4355,8 @@ async function launchRigOpenTuiApp(options) {
|
|
|
4729
4355
|
},
|
|
4730
4356
|
suspend: () => renderer?.suspend(),
|
|
4731
4357
|
resume: () => {
|
|
4732
|
-
renderer
|
|
4358
|
+
if (renderer)
|
|
4359
|
+
resumeRendererClean(renderer);
|
|
4733
4360
|
renderApp();
|
|
4734
4361
|
},
|
|
4735
4362
|
destroy: () => renderer?.destroy()
|