@h-rig/cli 0.0.6-alpha.83 → 0.0.6-alpha.85
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 +22060 -14620
- package/dist/src/app/board.js +155 -28
- package/dist/src/app-opentui/adapters/doctor.d.ts +0 -2
- package/dist/src/app-opentui/adapters/doctor.js +1 -25
- package/dist/src/app-opentui/adapters/family.d.ts +62 -0
- package/dist/src/app-opentui/adapters/family.js +14305 -0
- package/dist/src/app-opentui/adapters/fleet.d.ts +0 -2
- package/dist/src/app-opentui/adapters/fleet.js +6 -40
- package/dist/src/app-opentui/adapters/inbox.d.ts +12 -2
- package/dist/src/app-opentui/adapters/inbox.js +54 -59
- package/dist/src/app-opentui/adapters/init.d.ts +0 -2
- package/dist/src/app-opentui/adapters/init.js +0 -26
- package/dist/src/app-opentui/adapters/inspect.d.ts +52 -0
- package/dist/src/app-opentui/adapters/inspect.js +1024 -0
- package/dist/src/app-opentui/adapters/pi-attach.d.ts +15 -6
- package/dist/src/app-opentui/adapters/pi-attach.js +348 -93
- package/dist/src/app-opentui/adapters/pi.d.ts +23 -0
- package/dist/src/app-opentui/adapters/pi.js +363 -0
- package/dist/src/app-opentui/adapters/plugin.d.ts +84 -0
- package/dist/src/app-opentui/adapters/plugin.js +544 -0
- package/dist/src/app-opentui/adapters/repo.d.ts +37 -0
- package/dist/src/app-opentui/adapters/repo.js +186 -0
- package/dist/src/app-opentui/adapters/run-detail.d.ts +9 -2
- package/dist/src/app-opentui/adapters/run-detail.js +97 -44
- package/dist/src/app-opentui/adapters/server.d.ts +10 -2
- package/dist/src/app-opentui/adapters/server.js +96 -27
- package/dist/src/app-opentui/adapters/tasks.d.ts +0 -2
- package/dist/src/app-opentui/adapters/tasks.js +437 -105
- package/dist/src/app-opentui/adapters/workspace.d.ts +49 -0
- package/dist/src/app-opentui/adapters/workspace.js +333 -0
- package/dist/src/app-opentui/autocomplete.d.ts +20 -0
- package/dist/src/app-opentui/autocomplete.js +576 -0
- package/dist/src/app-opentui/bootstrap.js +24313 -16963
- package/dist/src/app-opentui/command-palette.d.ts +3 -0
- package/dist/src/app-opentui/command-palette.js +1010 -0
- package/dist/src/app-opentui/drone.js +8 -6
- package/dist/src/app-opentui/fleet-stats.d.ts +32 -0
- package/dist/src/app-opentui/fleet-stats.js +114 -0
- package/dist/src/app-opentui/index.js +3438 -1724
- package/dist/src/app-opentui/intent.js +71 -48
- package/dist/src/app-opentui/keymap.d.ts +6 -5
- package/dist/src/app-opentui/keymap.js +1064 -23
- package/dist/src/app-opentui/layout.d.ts +7 -0
- package/dist/src/app-opentui/layout.js +13 -6
- package/dist/src/app-opentui/list-search.d.ts +24 -0
- package/dist/src/app-opentui/list-search.js +88 -1
- package/dist/src/app-opentui/pi-host-child.js +33 -1
- package/dist/src/app-opentui/pi-pty-host.d.ts +5 -0
- package/dist/src/app-opentui/pi-pty-host.js +21 -3
- package/dist/src/app-opentui/react/App.d.ts +9 -0
- package/dist/src/app-opentui/react/App.js +5099 -0
- package/dist/src/app-opentui/react/Backdrop.d.ts +5 -0
- package/dist/src/app-opentui/react/Backdrop.js +829 -0
- package/dist/src/app-opentui/react/ChromeHost.d.ts +5 -0
- package/dist/src/app-opentui/react/ChromeHost.js +2942 -0
- package/dist/src/app-opentui/react/SceneFrameView.d.ts +7 -0
- package/dist/src/app-opentui/react/SceneFrameView.js +529 -0
- package/dist/src/app-opentui/react/context.d.ts +17 -0
- package/dist/src/app-opentui/react/context.js +37 -0
- package/dist/src/app-opentui/react/launch.d.ts +2 -0
- package/dist/src/app-opentui/react/launch.js +5698 -0
- package/dist/src/app-opentui/react/nav.d.ts +18 -0
- package/dist/src/app-opentui/react/nav.js +54 -0
- package/dist/src/app-opentui/react/scroll.d.ts +12 -0
- package/dist/src/app-opentui/react/scroll.js +21 -0
- package/dist/src/app-opentui/react/syntax.d.ts +2 -0
- package/dist/src/app-opentui/react/syntax.js +64 -0
- package/dist/src/app-opentui/registry.js +19923 -5151
- package/dist/src/app-opentui/render/constants.d.ts +31 -0
- package/dist/src/app-opentui/render/constants.js +66 -0
- package/dist/src/app-opentui/render/graphics.d.ts +2 -1
- package/dist/src/app-opentui/render/graphics.js +106 -39
- package/dist/src/app-opentui/render/image-visual-layer-worker.js +108 -20
- package/dist/src/app-opentui/render/image-visual-layer.d.ts +7 -0
- package/dist/src/app-opentui/render/image-visual-layer.js +109 -20
- package/dist/src/app-opentui/render/native-host.d.ts +37 -0
- package/dist/src/app-opentui/render/native-host.js +179 -0
- package/dist/src/app-opentui/render/panels.js +18 -11
- package/dist/src/app-opentui/render/preloader.js +8 -6
- package/dist/src/app-opentui/render/scene.d.ts +50 -1
- package/dist/src/app-opentui/render/scene.js +183 -6
- package/dist/src/app-opentui/render/text.d.ts +7 -1
- package/dist/src/app-opentui/render/text.js +10 -7
- package/dist/src/app-opentui/render/type-bar.js +69 -30
- package/dist/src/app-opentui/runtime.d.ts +44 -1
- package/dist/src/app-opentui/runtime.js +3231 -1363
- package/dist/src/app-opentui/scenes/command.js +20 -6
- package/dist/src/app-opentui/scenes/doctor.js +176 -11
- package/dist/src/app-opentui/scenes/error.js +20 -10
- package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/agent.js +348 -0
- package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/browser.js +195 -0
- package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/dist.js +243 -0
- package/dist/src/app-opentui/scenes/family-domains/git.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/git.js +195 -0
- package/dist/src/app-opentui/scenes/family-domains/github.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/github.js +274 -0
- package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/harness.js +152 -0
- package/dist/src/app-opentui/scenes/family-domains/index.d.ts +4 -0
- package/dist/src/app-opentui/scenes/family-domains/index.js +1679 -0
- package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +76 -0
- package/dist/src/app-opentui/scenes/family-domains/kit.js +305 -0
- package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/profile.js +212 -0
- package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/queue.js +146 -0
- package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/remote.js +518 -0
- package/dist/src/app-opentui/scenes/family-domains/review.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/review.js +280 -0
- package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/setup.js +267 -0
- package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/stats.js +370 -0
- package/dist/src/app-opentui/scenes/family.d.ts +3 -0
- package/dist/src/app-opentui/scenes/family.js +2144 -0
- package/dist/src/app-opentui/scenes/fleet.js +521 -31
- package/dist/src/app-opentui/scenes/handoff.js +204 -12
- package/dist/src/app-opentui/scenes/help.js +609 -40
- package/dist/src/app-opentui/scenes/inbox.js +278 -17
- package/dist/src/app-opentui/scenes/init.js +84 -39
- package/dist/src/app-opentui/scenes/inspect.d.ts +3 -0
- package/dist/src/app-opentui/scenes/inspect.js +793 -0
- package/dist/src/app-opentui/scenes/main.js +218 -39
- package/dist/src/app-opentui/scenes/pi.d.ts +3 -0
- package/dist/src/app-opentui/scenes/pi.js +508 -0
- package/dist/src/app-opentui/scenes/plugin.d.ts +3 -0
- package/dist/src/app-opentui/scenes/plugin.js +486 -0
- package/dist/src/app-opentui/scenes/repo.d.ts +3 -0
- package/dist/src/app-opentui/scenes/repo.js +424 -0
- package/dist/src/app-opentui/scenes/run-detail.js +333 -20
- package/dist/src/app-opentui/scenes/server.js +181 -15
- package/dist/src/app-opentui/scenes/tasks.js +486 -31
- package/dist/src/app-opentui/scenes/workspace.d.ts +3 -0
- package/dist/src/app-opentui/scenes/workspace.js +426 -0
- package/dist/src/app-opentui/selectable.d.ts +19 -0
- package/dist/src/app-opentui/selectable.js +79 -0
- package/dist/src/app-opentui/state.js +83 -30
- package/dist/src/app-opentui/surface-catalog.d.ts +20 -0
- package/dist/src/app-opentui/surface-catalog.js +540 -0
- package/dist/src/app-opentui/theme.d.ts +28 -6
- package/dist/src/app-opentui/theme.js +61 -8
- package/dist/src/app-opentui/types.d.ts +121 -4
- package/dist/src/commands/_authority-runs.d.ts +1 -1
- package/dist/src/commands/_authority-runs.js +2 -12
- package/dist/src/commands/_help-catalog.js +95 -15
- package/dist/src/commands/_operator-view.js +34 -2
- package/dist/src/commands/_pi-frontend.d.ts +2 -0
- package/dist/src/commands/_pi-frontend.js +34 -0
- package/dist/src/commands/_server-events.d.ts +26 -0
- package/dist/src/commands/_server-events.js +310 -0
- package/dist/src/commands/agent.js +2 -12
- package/dist/src/commands/run.js +34 -2
- package/dist/src/commands/server.js +2 -12
- package/dist/src/commands/stats.js +95 -15
- package/dist/src/commands/task-run-driver.js +2 -12
- package/dist/src/commands/task.js +131 -29
- package/dist/src/commands.js +192 -31
- package/dist/src/index.js +192 -31
- package/package.json +11 -9
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StageLayout } from "../layout";
|
|
2
|
+
import type { AppSceneFrame, AppSceneLine } from "../types";
|
|
3
|
+
export declare function SceneFrameView(props: {
|
|
4
|
+
frame: AppSceneFrame;
|
|
5
|
+
layout: StageLayout;
|
|
6
|
+
onLineClick?: (line: AppSceneLine) => void;
|
|
7
|
+
}): React.ReactNode;
|
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/cli/src/app-opentui/react/SceneFrameView.tsx
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { useRenderer } from "@opentui/react";
|
|
5
|
+
import { TextAttributes as TextAttributes4 } from "@opentui/core";
|
|
6
|
+
|
|
7
|
+
// packages/cli/src/app-opentui/theme.ts
|
|
8
|
+
import {
|
|
9
|
+
bold as otuiBold,
|
|
10
|
+
dim as otuiDim,
|
|
11
|
+
fg as otuiFg,
|
|
12
|
+
t,
|
|
13
|
+
TextAttributes
|
|
14
|
+
} from "@opentui/core";
|
|
15
|
+
var RIG_UI = {
|
|
16
|
+
bg: "#070809",
|
|
17
|
+
bg2: "#0b0c0e",
|
|
18
|
+
panel: "#101115",
|
|
19
|
+
panel2: "#14161b",
|
|
20
|
+
glass: "#1e2230",
|
|
21
|
+
border: "#2a2e3a",
|
|
22
|
+
ink: "#f4f5f8",
|
|
23
|
+
ink2: "#c7c9d3",
|
|
24
|
+
ink3: "#9aa0ae",
|
|
25
|
+
ink4: "#787b86",
|
|
26
|
+
lime: "#ccff4d",
|
|
27
|
+
limeDim: "#a9d63f",
|
|
28
|
+
cyan: "#56d8ff",
|
|
29
|
+
cyanDim: "#3f9fbd",
|
|
30
|
+
red: "#ff5d5d",
|
|
31
|
+
yellow: "#ffd24d",
|
|
32
|
+
magenta: "#ff79b0"
|
|
33
|
+
};
|
|
34
|
+
var styles = {
|
|
35
|
+
ink: otuiFg(RIG_UI.ink),
|
|
36
|
+
ink2: otuiFg(RIG_UI.ink2),
|
|
37
|
+
ink3: otuiFg(RIG_UI.ink3),
|
|
38
|
+
ink4: otuiFg(RIG_UI.ink4),
|
|
39
|
+
lime: otuiFg(RIG_UI.lime),
|
|
40
|
+
limeDim: otuiFg(RIG_UI.limeDim),
|
|
41
|
+
cyan: otuiFg(RIG_UI.cyan),
|
|
42
|
+
red: otuiFg(RIG_UI.red),
|
|
43
|
+
yellow: otuiFg(RIG_UI.yellow),
|
|
44
|
+
magenta: otuiFg(RIG_UI.magenta)
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// packages/cli/src/app-opentui/layout.ts
|
|
48
|
+
function visibleWidth(text) {
|
|
49
|
+
return [...text].length;
|
|
50
|
+
}
|
|
51
|
+
function alignText(text, width, align = "left") {
|
|
52
|
+
const length = visibleWidth(text);
|
|
53
|
+
if (length >= width)
|
|
54
|
+
return text;
|
|
55
|
+
const pad = width - length;
|
|
56
|
+
if (align === "right")
|
|
57
|
+
return `${" ".repeat(pad)}${text}`;
|
|
58
|
+
if (align === "center") {
|
|
59
|
+
const left = Math.floor(pad / 2);
|
|
60
|
+
return `${" ".repeat(left)}${text}${" ".repeat(pad - left)}`;
|
|
61
|
+
}
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
function truncateText(text, width) {
|
|
65
|
+
if (visibleWidth(text) <= width)
|
|
66
|
+
return text;
|
|
67
|
+
if (width <= 1)
|
|
68
|
+
return "\u2026";
|
|
69
|
+
return `${[...text].slice(0, Math.max(0, width - 1)).join("")}\u2026`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// packages/cli/src/app-opentui/drone.ts
|
|
73
|
+
import { RGBA, StyledText, TextAttributes as TextAttributes2 } from "@opentui/core";
|
|
74
|
+
var COLOR = {
|
|
75
|
+
body: RGBA.fromHex(RIG_UI.lime),
|
|
76
|
+
mini: RGBA.fromHex(RIG_UI.limeDim),
|
|
77
|
+
rotor: RGBA.fromHex(RIG_UI.cyan),
|
|
78
|
+
path: RGBA.fromHex(RIG_UI.cyan),
|
|
79
|
+
eye: RGBA.fromHex(RIG_UI.ink),
|
|
80
|
+
dim: RGBA.fromHex(RIG_UI.ink4),
|
|
81
|
+
ink: RGBA.fromHex(RIG_UI.ink2)
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// packages/cli/src/app-opentui/render/scene.ts
|
|
85
|
+
function fitSceneLine(input, layout) {
|
|
86
|
+
const fitted = truncateText(input.text, layout.centerWidth);
|
|
87
|
+
return {
|
|
88
|
+
...input,
|
|
89
|
+
text: alignText(fitted, layout.centerWidth, input.align ?? "left")
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function fitSceneLines(lines, layout) {
|
|
93
|
+
return lines.slice(0, layout.centerHeight).map((entry) => fitSceneLine(entry, layout));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// packages/cli/src/app-opentui/render/text.ts
|
|
97
|
+
import { RGBA as RGBA2, TextAttributes as TextAttributes3, TextRenderable } from "@opentui/core";
|
|
98
|
+
var TRANSPARENT = RGBA2.fromInts(0, 0, 0, 0);
|
|
99
|
+
function selectableMouseHandler(currentLineRef, onLineMouseDown) {
|
|
100
|
+
return (event) => {
|
|
101
|
+
const currentLine = currentLineRef();
|
|
102
|
+
if (currentLine?.selectableIndex === undefined)
|
|
103
|
+
return;
|
|
104
|
+
onLineMouseDown?.(currentLine, event);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function createFlowTextLine(renderer, id, onLineMouseDown) {
|
|
108
|
+
let currentLine;
|
|
109
|
+
const renderable = new TextRenderable(renderer, {
|
|
110
|
+
id,
|
|
111
|
+
content: "",
|
|
112
|
+
width: "100%",
|
|
113
|
+
height: 1,
|
|
114
|
+
flexShrink: 0,
|
|
115
|
+
fg: RIG_UI.ink2,
|
|
116
|
+
selectable: true,
|
|
117
|
+
onMouseDown: selectableMouseHandler(() => currentLine, onLineMouseDown)
|
|
118
|
+
});
|
|
119
|
+
renderable.setRigSceneLine = (line) => {
|
|
120
|
+
currentLine = line;
|
|
121
|
+
};
|
|
122
|
+
return renderable;
|
|
123
|
+
}
|
|
124
|
+
function applyFlowTextLine(renderable, line, width) {
|
|
125
|
+
renderable.setRigSceneLine?.(line);
|
|
126
|
+
renderable.visible = Boolean(line);
|
|
127
|
+
renderable.height = line ? 1 : 0;
|
|
128
|
+
renderable.width = Math.max(1, width);
|
|
129
|
+
renderable.content = line?.styledText ?? line?.text ?? "";
|
|
130
|
+
renderable.fg = line?.fg ?? RIG_UI.ink2;
|
|
131
|
+
renderable.bg = line?.bg ?? TRANSPARENT;
|
|
132
|
+
renderable.attributes = line?.bold ? TextAttributes3.BOLD : line?.dim ? TextAttributes3.DIM : 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// packages/cli/src/app-opentui/render/panels.ts
|
|
136
|
+
import { RGBA as RGBA3, ScrollBoxRenderable } from "@opentui/core";
|
|
137
|
+
|
|
138
|
+
// packages/cli/src/app-opentui/render/panel-layout.ts
|
|
139
|
+
function panelCellRect(layout, panel) {
|
|
140
|
+
const left = Math.max(0, Math.min(layout.width - 1, layout.centerLeft + (panel.left ?? 0)));
|
|
141
|
+
const desiredWidth = panel.width ?? layout.centerWidth;
|
|
142
|
+
const width = Math.max(1, Math.min(layout.width - left, desiredWidth));
|
|
143
|
+
const top = Math.max(0, Math.min(layout.height - 1, layout.centerTop + panel.top));
|
|
144
|
+
const height = Math.max(1, Math.min(layout.height - top, panel.height));
|
|
145
|
+
if (width <= 3 || height <= 3)
|
|
146
|
+
return null;
|
|
147
|
+
const right = left + width - 1;
|
|
148
|
+
const bottom = top + height - 1;
|
|
149
|
+
const headerHeight = panel.chrome === "ad-terminal" ? Math.max(3, Math.min(height - 2, panel.headerHeight ?? 3)) : 0;
|
|
150
|
+
const dividerY = headerHeight ? Math.min(bottom - 1, top + headerHeight) : top;
|
|
151
|
+
return { left, top, width, height, right, bottom, headerHeight, dividerY };
|
|
152
|
+
}
|
|
153
|
+
function panelContentRect(layout, panel) {
|
|
154
|
+
const rect = panelCellRect(layout, panel);
|
|
155
|
+
if (!rect)
|
|
156
|
+
return null;
|
|
157
|
+
const chromeInset = panel.chrome === "ad-terminal" ? 1 : 0;
|
|
158
|
+
const left = rect.left + chromeInset;
|
|
159
|
+
const top = rect.top + rect.headerHeight + chromeInset;
|
|
160
|
+
const width = Math.max(1, Math.min(layout.width - left, rect.width - chromeInset * 2));
|
|
161
|
+
const height = Math.max(1, Math.min(layout.height - top, rect.height - rect.headerHeight - chromeInset * 2));
|
|
162
|
+
const paddingX = panel.paddingX ?? (panel.chrome === "ad-terminal" ? 5 : 2);
|
|
163
|
+
const paddingY = panel.paddingY ?? (panel.chrome === "ad-terminal" ? 2 : 1);
|
|
164
|
+
const contentWidth = Math.max(1, width - paddingX * 2 - 1);
|
|
165
|
+
return { left, top, width, height, paddingX, paddingY, contentWidth };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// packages/cli/src/app-opentui/render/panels.ts
|
|
169
|
+
var TRANSPARENT2 = RGBA3.fromInts(0, 0, 0, 0);
|
|
170
|
+
var MAX_PANEL_LINES = 420;
|
|
171
|
+
var PANEL_OPAQUE_ALPHA = 255;
|
|
172
|
+
var PANEL_BORDER = hexToRgba(RIG_UI.border, 255);
|
|
173
|
+
function hexToRgba(hex, alpha) {
|
|
174
|
+
const clean = hex.replace(/^#/, "");
|
|
175
|
+
const full = clean.length === 3 ? clean.split("").map((part) => `${part}${part}`).join("") : clean;
|
|
176
|
+
const value = Number.parseInt(full, 16);
|
|
177
|
+
if (!Number.isFinite(value))
|
|
178
|
+
return RGBA3.fromInts(14, 15, 17, alpha);
|
|
179
|
+
return RGBA3.fromInts(value >> 16 & 255, value >> 8 & 255, value & 255, alpha);
|
|
180
|
+
}
|
|
181
|
+
function panelBackground(panel) {
|
|
182
|
+
return hexToRgba(panel.backgroundColor ?? RIG_UI.panel, PANEL_OPAQUE_ALPHA);
|
|
183
|
+
}
|
|
184
|
+
function panelBorder(panel) {
|
|
185
|
+
if (panel.borderColor)
|
|
186
|
+
return hexToRgba(panel.borderColor, panel.borderAlpha ?? 255);
|
|
187
|
+
return PANEL_BORDER;
|
|
188
|
+
}
|
|
189
|
+
function createScrollPanelLayer(renderer, id, onLineMouseDown) {
|
|
190
|
+
const panel = new ScrollBoxRenderable(renderer, {
|
|
191
|
+
id,
|
|
192
|
+
position: "absolute",
|
|
193
|
+
left: 0,
|
|
194
|
+
top: -2,
|
|
195
|
+
width: 1,
|
|
196
|
+
height: 1,
|
|
197
|
+
backgroundColor: TRANSPARENT2,
|
|
198
|
+
border: false,
|
|
199
|
+
shouldFill: true,
|
|
200
|
+
opacity: 1,
|
|
201
|
+
zIndex: 6,
|
|
202
|
+
scrollY: true,
|
|
203
|
+
scrollX: false,
|
|
204
|
+
stickyScroll: false,
|
|
205
|
+
viewportCulling: true,
|
|
206
|
+
paddingX: 2,
|
|
207
|
+
paddingY: 1,
|
|
208
|
+
verticalScrollbarOptions: {
|
|
209
|
+
showArrows: false,
|
|
210
|
+
visible: false,
|
|
211
|
+
width: 1,
|
|
212
|
+
trackOptions: {
|
|
213
|
+
backgroundColor: TRANSPARENT2,
|
|
214
|
+
foregroundColor: hexToRgba(RIG_UI.ink4, 84)
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
horizontalScrollbarOptions: {
|
|
218
|
+
height: 0,
|
|
219
|
+
visible: false,
|
|
220
|
+
trackOptions: {
|
|
221
|
+
backgroundColor: TRANSPARENT2,
|
|
222
|
+
foregroundColor: TRANSPARENT2
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
panel.__rigTextLines = [];
|
|
227
|
+
panel.__rigRenderer = renderer;
|
|
228
|
+
panel.__rigOnLineMouseDown = onLineMouseDown;
|
|
229
|
+
return panel;
|
|
230
|
+
}
|
|
231
|
+
function ensurePanelLineCount(panel, desiredCount) {
|
|
232
|
+
const target = Math.min(MAX_PANEL_LINES, Math.max(0, desiredCount));
|
|
233
|
+
while (panel.__rigTextLines.length < target) {
|
|
234
|
+
const index = panel.__rigTextLines.length;
|
|
235
|
+
const line = createFlowTextLine(panel.__rigRenderer, `${panel.id}-line-${index}`, panel.__rigOnLineMouseDown);
|
|
236
|
+
panel.__rigTextLines.push(line);
|
|
237
|
+
panel.add(line);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function hidePanel(panel) {
|
|
241
|
+
panel.visible = false;
|
|
242
|
+
panel.top = -2;
|
|
243
|
+
panel.left = 0;
|
|
244
|
+
panel.width = 1;
|
|
245
|
+
panel.height = 1;
|
|
246
|
+
panel.backgroundColor = TRANSPARENT2;
|
|
247
|
+
panel.border = false;
|
|
248
|
+
panel.__rigPanelId = undefined;
|
|
249
|
+
panel.__rigTextLines.forEach((line) => applyFlowTextLine(line, undefined, 1));
|
|
250
|
+
}
|
|
251
|
+
function applyScrollPanels(panels, layout, scenePanels) {
|
|
252
|
+
panels.forEach((renderable, index) => {
|
|
253
|
+
const panel = scenePanels[index];
|
|
254
|
+
if (!panel || panel.height <= 0) {
|
|
255
|
+
hidePanel(renderable);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const contentRect = panelContentRect(layout, panel);
|
|
259
|
+
if (!contentRect) {
|
|
260
|
+
hidePanel(renderable);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const { left, top, width, height, paddingX, paddingY, contentWidth } = contentRect;
|
|
264
|
+
renderable.visible = true;
|
|
265
|
+
renderable.left = left;
|
|
266
|
+
renderable.top = top;
|
|
267
|
+
renderable.width = width;
|
|
268
|
+
renderable.height = height;
|
|
269
|
+
renderable.zIndex = panel.zIndex ?? 6;
|
|
270
|
+
renderable.opacity = panel.opacity ?? 1;
|
|
271
|
+
const adTerminal = panel.chrome === "ad-terminal";
|
|
272
|
+
renderable.backgroundColor = adTerminal ? TRANSPARENT2 : panelBackground(panel);
|
|
273
|
+
renderable.border = adTerminal ? false : true;
|
|
274
|
+
renderable.borderColor = adTerminal ? TRANSPARENT2 : panelBorder(panel);
|
|
275
|
+
renderable.paddingX = paddingX;
|
|
276
|
+
renderable.paddingY = paddingY;
|
|
277
|
+
renderable.stickyScroll = panel.stickyScroll ?? false;
|
|
278
|
+
renderable.stickyStart = panel.stickyStart;
|
|
279
|
+
renderable.verticalScrollBar.visible = false;
|
|
280
|
+
renderable.horizontalScrollBar.visible = false;
|
|
281
|
+
if (renderable.__rigPanelId !== panel.id) {
|
|
282
|
+
renderable.__rigPanelId = panel.id;
|
|
283
|
+
renderable.scrollTo(0);
|
|
284
|
+
}
|
|
285
|
+
const lineCount = Math.min(panel.lines.length, MAX_PANEL_LINES);
|
|
286
|
+
ensurePanelLineCount(renderable, lineCount);
|
|
287
|
+
renderable.__rigTextLines.forEach((line, lineIndex) => {
|
|
288
|
+
applyFlowTextLine(line, lineIndex < lineCount ? panel.lines[lineIndex] : undefined, contentWidth);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// packages/cli/src/app-opentui/render/native-host.ts
|
|
294
|
+
import {
|
|
295
|
+
BoxRenderable,
|
|
296
|
+
CodeRenderable,
|
|
297
|
+
DiffRenderable,
|
|
298
|
+
RGBA as RGBA4,
|
|
299
|
+
ScrollBoxRenderable as ScrollBoxRenderable2,
|
|
300
|
+
SyntaxStyle,
|
|
301
|
+
TextRenderable as TextRenderable2,
|
|
302
|
+
TextTableRenderable
|
|
303
|
+
} from "@opentui/core";
|
|
304
|
+
var syntaxStyle = null;
|
|
305
|
+
function rigSyntaxStyle() {
|
|
306
|
+
if (syntaxStyle)
|
|
307
|
+
return syntaxStyle;
|
|
308
|
+
syntaxStyle = SyntaxStyle.fromStyles({
|
|
309
|
+
keyword: { fg: RGBA4.fromHex(RIG_UI.magenta), bold: true },
|
|
310
|
+
string: { fg: RGBA4.fromHex(RIG_UI.lime) },
|
|
311
|
+
number: { fg: RGBA4.fromHex(RIG_UI.cyan) },
|
|
312
|
+
comment: { fg: RGBA4.fromHex(RIG_UI.ink4), italic: true },
|
|
313
|
+
function: { fg: RGBA4.fromHex(RIG_UI.cyan) },
|
|
314
|
+
type: { fg: RGBA4.fromHex(RIG_UI.limeDim) },
|
|
315
|
+
constant: { fg: RGBA4.fromHex(RIG_UI.yellow) },
|
|
316
|
+
default: { fg: RGBA4.fromHex(RIG_UI.ink2) }
|
|
317
|
+
});
|
|
318
|
+
return syntaxStyle;
|
|
319
|
+
}
|
|
320
|
+
function tableContent(rows) {
|
|
321
|
+
return rows.map((row, rowIndex) => row.map((cell) => [{ __isChunk: true, text: cell, fg: RGBA4.fromHex(rowIndex === 0 ? RIG_UI.ink3 : RIG_UI.ink2) }]));
|
|
322
|
+
}
|
|
323
|
+
function createNativeHost(renderer) {
|
|
324
|
+
try {
|
|
325
|
+
const scrollBox = new ScrollBoxRenderable2(renderer, {
|
|
326
|
+
id: "rig-native-scrollbox",
|
|
327
|
+
position: "absolute",
|
|
328
|
+
left: 0,
|
|
329
|
+
top: 0,
|
|
330
|
+
width: 1,
|
|
331
|
+
height: 1,
|
|
332
|
+
scrollY: true,
|
|
333
|
+
zIndex: 9,
|
|
334
|
+
visible: false
|
|
335
|
+
});
|
|
336
|
+
renderer.root.add(scrollBox);
|
|
337
|
+
return { scrollBox, code: null, diff: null, table: null, active: null, lastKey: "" };
|
|
338
|
+
} catch {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function hideAllChildren(host) {
|
|
343
|
+
if (host.code)
|
|
344
|
+
host.code.visible = false;
|
|
345
|
+
if (host.diff)
|
|
346
|
+
host.diff.visible = false;
|
|
347
|
+
if (host.table)
|
|
348
|
+
host.table.visible = false;
|
|
349
|
+
}
|
|
350
|
+
function hideNativeHost(host) {
|
|
351
|
+
if (!host)
|
|
352
|
+
return;
|
|
353
|
+
host.scrollBox.visible = false;
|
|
354
|
+
hideAllChildren(host);
|
|
355
|
+
host.active = null;
|
|
356
|
+
}
|
|
357
|
+
function applyNativeHost(host, mount, layout) {
|
|
358
|
+
if (!host)
|
|
359
|
+
return false;
|
|
360
|
+
try {
|
|
361
|
+
const left = mount.left ?? layout.centerLeft;
|
|
362
|
+
const top = mount.top ?? layout.centerTop;
|
|
363
|
+
const width = Math.max(8, mount.width ?? layout.centerWidth);
|
|
364
|
+
const height = Math.max(3, mount.height ?? layout.centerHeight);
|
|
365
|
+
host.scrollBox.left = left;
|
|
366
|
+
host.scrollBox.top = top;
|
|
367
|
+
host.scrollBox.width = width;
|
|
368
|
+
host.scrollBox.height = height;
|
|
369
|
+
host.scrollBox.visible = true;
|
|
370
|
+
hideAllChildren(host);
|
|
371
|
+
const rowCount = mount.rows?.length ?? 0;
|
|
372
|
+
const key = `${mount.kind}:${width}x${height}:${mount.content.length}:${mount.filetype ?? ""}:${rowCount}`;
|
|
373
|
+
if (mount.kind === "table") {
|
|
374
|
+
if (!host.table) {
|
|
375
|
+
host.table = new TextTableRenderable(host.scrollBox.ctx, { id: "rig-native-table", content: [], width: "100%", showBorders: true, columnWidthMode: "full", borderColor: RIG_UI.ink4 });
|
|
376
|
+
host.scrollBox.add(host.table);
|
|
377
|
+
}
|
|
378
|
+
if (host.lastKey !== key)
|
|
379
|
+
host.table.content = tableContent(mount.rows ?? []);
|
|
380
|
+
host.table.visible = true;
|
|
381
|
+
} else if (mount.kind === "diff") {
|
|
382
|
+
if (!host.diff) {
|
|
383
|
+
host.diff = new DiffRenderable(host.scrollBox.ctx, { id: "rig-native-diff", diff: "", width: "100%" });
|
|
384
|
+
host.scrollBox.add(host.diff);
|
|
385
|
+
}
|
|
386
|
+
if (host.lastKey !== key)
|
|
387
|
+
host.diff.diff = mount.content;
|
|
388
|
+
host.diff.visible = true;
|
|
389
|
+
} else {
|
|
390
|
+
const filetype = mount.kind === "markdown" ? "markdown" : mount.filetype ?? "text";
|
|
391
|
+
if (!host.code) {
|
|
392
|
+
host.code = new CodeRenderable(host.scrollBox.ctx, { id: "rig-native-code", content: "", filetype, syntaxStyle: rigSyntaxStyle(), width: "100%" });
|
|
393
|
+
host.scrollBox.add(host.code);
|
|
394
|
+
}
|
|
395
|
+
if (host.lastKey !== key) {
|
|
396
|
+
host.code.filetype = filetype;
|
|
397
|
+
host.code.content = mount.content;
|
|
398
|
+
}
|
|
399
|
+
host.code.visible = true;
|
|
400
|
+
}
|
|
401
|
+
host.active = mount.kind;
|
|
402
|
+
host.lastKey = key;
|
|
403
|
+
if (mount.stickyBottom)
|
|
404
|
+
host.scrollBox.scrollTo?.({ x: 0, y: Number.MAX_SAFE_INTEGER });
|
|
405
|
+
return true;
|
|
406
|
+
} catch {
|
|
407
|
+
hideNativeHost(host);
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function destroyNativeHost(host) {
|
|
412
|
+
if (!host)
|
|
413
|
+
return;
|
|
414
|
+
try {
|
|
415
|
+
host.scrollBox.destroy?.();
|
|
416
|
+
} catch {}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// packages/cli/src/app-opentui/react/scroll.ts
|
|
420
|
+
var registries = new Set;
|
|
421
|
+
function registerScrollables(provider) {
|
|
422
|
+
registries.add(provider);
|
|
423
|
+
return () => {
|
|
424
|
+
registries.delete(provider);
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// packages/cli/src/app-opentui/react/SceneFrameView.tsx
|
|
429
|
+
import { jsxDEV, Fragment } from "@opentui/react/jsx-dev-runtime";
|
|
430
|
+
function lineAttributes(line) {
|
|
431
|
+
return line?.bold ? TextAttributes4.BOLD : line?.dim ? TextAttributes4.DIM : 0;
|
|
432
|
+
}
|
|
433
|
+
function lineContent(line) {
|
|
434
|
+
return line.styledText ?? line.text ?? "";
|
|
435
|
+
}
|
|
436
|
+
function LineView(props) {
|
|
437
|
+
const { line, onLineClick } = props;
|
|
438
|
+
return /* @__PURE__ */ jsxDEV("text", {
|
|
439
|
+
style: { position: "absolute", left: props.left, top: props.top, width: props.width, zIndex: 5 },
|
|
440
|
+
fg: line.fg ?? RIG_UI.ink2,
|
|
441
|
+
bg: line.bg ?? TRANSPARENT,
|
|
442
|
+
attributes: lineAttributes(line),
|
|
443
|
+
content: lineContent(line),
|
|
444
|
+
onMouseDown: onLineClick ? () => onLineClick(line) : undefined
|
|
445
|
+
}, undefined, false, undefined, this);
|
|
446
|
+
}
|
|
447
|
+
function PanelHost(props) {
|
|
448
|
+
const renderer = useRenderer();
|
|
449
|
+
const poolRef = useRef([]);
|
|
450
|
+
const clickRef = useRef(props.onLineClick);
|
|
451
|
+
clickRef.current = props.onLineClick;
|
|
452
|
+
useEffect(() => {
|
|
453
|
+
const unregister = registerScrollables(() => poolRef.current);
|
|
454
|
+
return () => {
|
|
455
|
+
unregister();
|
|
456
|
+
for (const panel of poolRef.current) {
|
|
457
|
+
try {
|
|
458
|
+
renderer.root.remove(panel.id);
|
|
459
|
+
} catch {}
|
|
460
|
+
}
|
|
461
|
+
poolRef.current = [];
|
|
462
|
+
};
|
|
463
|
+
}, [renderer]);
|
|
464
|
+
useEffect(() => {
|
|
465
|
+
const pool = poolRef.current;
|
|
466
|
+
while (pool.length < props.panels.length) {
|
|
467
|
+
const panel = createScrollPanelLayer(renderer, `react-scroll-panel-${pool.length}`, (line) => clickRef.current?.(line));
|
|
468
|
+
renderer.root.add(panel);
|
|
469
|
+
pool.push(panel);
|
|
470
|
+
}
|
|
471
|
+
applyScrollPanels(pool, props.layout, props.panels);
|
|
472
|
+
});
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
function NativeHostView(props) {
|
|
476
|
+
const renderer = useRenderer();
|
|
477
|
+
const hostRef = useRef(null);
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
const host = createNativeHost(renderer);
|
|
480
|
+
hostRef.current = host;
|
|
481
|
+
const unregister = registerScrollables(() => host ? [host.scrollBox] : []);
|
|
482
|
+
return () => {
|
|
483
|
+
unregister();
|
|
484
|
+
destroyNativeHost(hostRef.current);
|
|
485
|
+
hostRef.current = null;
|
|
486
|
+
};
|
|
487
|
+
}, [renderer]);
|
|
488
|
+
useEffect(() => {
|
|
489
|
+
const host = hostRef.current;
|
|
490
|
+
if (!host)
|
|
491
|
+
return;
|
|
492
|
+
if (props.native) {
|
|
493
|
+
if (!applyNativeHost(host, props.native, props.layout))
|
|
494
|
+
hideNativeHost(host);
|
|
495
|
+
} else {
|
|
496
|
+
hideNativeHost(host);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
function SceneFrameView(props) {
|
|
502
|
+
const { frame, layout } = props;
|
|
503
|
+
const contentLayout = frame.fullScreen ? { ...layout, centerWidth: layout.width, centerLeft: 0, centerTop: 0 } : layout;
|
|
504
|
+
const lines = fitSceneLines(frame.lines ?? [], contentLayout);
|
|
505
|
+
const nativeActive = frame.native && !frame.terminalActive;
|
|
506
|
+
return /* @__PURE__ */ jsxDEV(Fragment, {
|
|
507
|
+
children: [
|
|
508
|
+
lines.map((line, index) => /* @__PURE__ */ jsxDEV(LineView, {
|
|
509
|
+
line,
|
|
510
|
+
top: contentLayout.centerTop + index,
|
|
511
|
+
left: contentLayout.centerLeft,
|
|
512
|
+
width: contentLayout.centerWidth,
|
|
513
|
+
onLineClick: props.onLineClick
|
|
514
|
+
}, `line-${index}`, false, undefined, this)),
|
|
515
|
+
/* @__PURE__ */ jsxDEV(PanelHost, {
|
|
516
|
+
panels: frame.panels ?? [],
|
|
517
|
+
layout: contentLayout,
|
|
518
|
+
onLineClick: props.onLineClick
|
|
519
|
+
}, undefined, false, undefined, this),
|
|
520
|
+
/* @__PURE__ */ jsxDEV(NativeHostView, {
|
|
521
|
+
native: nativeActive ? frame.native : undefined,
|
|
522
|
+
layout: contentLayout
|
|
523
|
+
}, undefined, false, undefined, this)
|
|
524
|
+
]
|
|
525
|
+
}, undefined, true, undefined, this);
|
|
526
|
+
}
|
|
527
|
+
export {
|
|
528
|
+
SceneFrameView
|
|
529
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AppRuntime, AppState, AppStore } from "../types";
|
|
2
|
+
type RigAppContextValue = {
|
|
3
|
+
readonly store: AppStore;
|
|
4
|
+
readonly runtime: AppRuntime;
|
|
5
|
+
readonly runAppAction: (label: string, action: () => Promise<unknown>) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function RigAppProvider(props: {
|
|
8
|
+
value: RigAppContextValue;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}): React.ReactNode;
|
|
11
|
+
export declare function useAppState(): AppState;
|
|
12
|
+
export declare function useRuntime(): AppRuntime;
|
|
13
|
+
/** The raw store — needed by the reused legacy selection helpers
|
|
14
|
+
* (moveSelection/selectIndex/selectById) which operate on the store directly. */
|
|
15
|
+
export declare function useStore(): AppStore;
|
|
16
|
+
export declare function useRunAppAction(): RigAppContextValue["runAppAction"];
|
|
17
|
+
export type { RigAppContextValue };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/cli/src/app-opentui/react/context.tsx
|
|
3
|
+
import { createContext, useContext, useSyncExternalStore } from "react";
|
|
4
|
+
import { jsxDEV } from "@opentui/react/jsx-dev-runtime";
|
|
5
|
+
var RigAppContext = createContext(null);
|
|
6
|
+
function RigAppProvider(props) {
|
|
7
|
+
return /* @__PURE__ */ jsxDEV(RigAppContext.Provider, {
|
|
8
|
+
value: props.value,
|
|
9
|
+
children: props.children
|
|
10
|
+
}, undefined, false, undefined, this);
|
|
11
|
+
}
|
|
12
|
+
function useCtx() {
|
|
13
|
+
const value = useContext(RigAppContext);
|
|
14
|
+
if (!value)
|
|
15
|
+
throw new Error("Rig react components must render inside <RigAppProvider>.");
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function useAppState() {
|
|
19
|
+
const { store } = useCtx();
|
|
20
|
+
return useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
21
|
+
}
|
|
22
|
+
function useRuntime() {
|
|
23
|
+
return useCtx().runtime;
|
|
24
|
+
}
|
|
25
|
+
function useStore() {
|
|
26
|
+
return useCtx().store;
|
|
27
|
+
}
|
|
28
|
+
function useRunAppAction() {
|
|
29
|
+
return useCtx().runAppAction;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
useStore,
|
|
33
|
+
useRuntime,
|
|
34
|
+
useRunAppAction,
|
|
35
|
+
useAppState,
|
|
36
|
+
RigAppProvider
|
|
37
|
+
};
|