okengine 0.2.1 → 0.2.2
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/README.md +8 -8
- package/package.json +2 -1
- package/src/cli/dev-app-runner.ts +6 -2
- package/src/cli/dev.ts +16 -9
- package/src/console/server/claim.test.ts +7 -4
- package/src/console/server/claim.ts +2 -7
- package/src/console/ui/dist/assets/index-B71Yl_SS.js +10 -0
- package/src/console/ui/dist/assets/panel-access-Dd37LU2c.js +64 -0
- package/src/console/ui/dist/assets/panel-ai-CC7LR6-J.js +1 -0
- package/src/console/ui/dist/assets/panel-architecture-B5b3iKCz.js +1 -0
- package/src/console/ui/dist/assets/panel-channels-CeNjTKXp.js +1 -0
- package/src/console/ui/dist/assets/panel-clock-DgFTLoHV.js +1 -0
- package/src/console/ui/dist/assets/panel-diff-DxehccqB.js +1 -0
- package/src/console/ui/dist/assets/panel-flows-BtrVn-Eg.js +45 -0
- package/src/console/ui/dist/assets/panel-gates-Z9MKRGdH.js +1 -0
- package/src/console/ui/dist/assets/panel-overview-Bd48d9km.js +1 -0
- package/src/console/ui/dist/assets/panel-plugins-DWd0TowH.js +1 -0
- package/src/console/ui/dist/assets/panel-runs-BwsWqKeB.js +1 -0
- package/src/console/ui/dist/assets/panel-signals-9najbZY2.js +1 -0
- package/src/console/ui/dist/assets/panel-store-OHkP2pDp.js +1 -0
- package/src/console/ui/dist/assets/panel-traces-tn2JoY8U.js +1 -0
- package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +1 -0
- package/src/console/ui/dist/assets/rolldown-runtime-CNC7AqOf.js +1 -0
- package/src/console/ui/dist/assets/style-Cnl7WLya.css +3 -0
- package/src/console/ui/dist/index.html +14 -0
- package/src/docs-origin.ts +19 -0
- package/src/kernel/errors.registry.test.ts +4 -2
- package/src/kernel/errors.ts +3 -1
- package/src/kernel/fx.test.ts +2 -2
- package/src/term.test.ts +51 -0
- package/src/term.ts +158 -0
package/src/term.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clack-inspired terminal styling for `oke` CLI / boot logs.
|
|
3
|
+
*
|
|
4
|
+
* Human TTY gets color + unicode chrome; CI / pipes stay plain.
|
|
5
|
+
* Flip to monochrome with `NO_COLOR=1` or non-TTY stdout.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Whether ANSI color should be applied. */
|
|
9
|
+
export function termColorEnabled(
|
|
10
|
+
stream: { readonly isTTY?: boolean } = process.stdout,
|
|
11
|
+
): boolean {
|
|
12
|
+
if (process.env["NO_COLOR"] !== undefined) return false;
|
|
13
|
+
if (process.env["FORCE_COLOR"] === "0") return false;
|
|
14
|
+
if (process.env["FORCE_COLOR"]) return true;
|
|
15
|
+
return stream.isTTY === true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ESC = "\u001b[";
|
|
19
|
+
|
|
20
|
+
/** ANSI helpers — empty strings when color is off. */
|
|
21
|
+
export type TermStyle = {
|
|
22
|
+
readonly reset: string;
|
|
23
|
+
readonly bold: string;
|
|
24
|
+
readonly dim: string;
|
|
25
|
+
readonly cyan: string;
|
|
26
|
+
readonly green: string;
|
|
27
|
+
readonly magenta: string;
|
|
28
|
+
readonly yellow: string;
|
|
29
|
+
readonly white: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Build a style palette for the current environment.
|
|
34
|
+
*
|
|
35
|
+
* @param color - Force on/off; default from {@link termColorEnabled}
|
|
36
|
+
*/
|
|
37
|
+
export function termStyle(color: boolean = termColorEnabled()): TermStyle {
|
|
38
|
+
if (!color) {
|
|
39
|
+
return {
|
|
40
|
+
reset: "",
|
|
41
|
+
bold: "",
|
|
42
|
+
dim: "",
|
|
43
|
+
cyan: "",
|
|
44
|
+
green: "",
|
|
45
|
+
magenta: "",
|
|
46
|
+
yellow: "",
|
|
47
|
+
white: "",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
reset: `${ESC}0m`,
|
|
52
|
+
bold: `${ESC}1m`,
|
|
53
|
+
dim: `${ESC}2m`,
|
|
54
|
+
cyan: `${ESC}36m`,
|
|
55
|
+
green: `${ESC}32m`,
|
|
56
|
+
magenta: `${ESC}35m`,
|
|
57
|
+
yellow: `${ESC}33m`,
|
|
58
|
+
white: `${ESC}37m`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* `oke dev` intro — clack chrome; service URLs print as each surface binds.
|
|
64
|
+
*
|
|
65
|
+
* @param options - Color / watch hint
|
|
66
|
+
*/
|
|
67
|
+
export function formatDevBanner(
|
|
68
|
+
options: { readonly color?: boolean; readonly watching?: boolean } = {},
|
|
69
|
+
): string {
|
|
70
|
+
const s = termStyle(options.color ?? termColorEnabled());
|
|
71
|
+
const bar = `${s.dim}│${s.reset}`;
|
|
72
|
+
const lines = [
|
|
73
|
+
"",
|
|
74
|
+
`${s.cyan}${s.bold}┌${s.reset} ${s.bold}oke dev${s.reset}`,
|
|
75
|
+
bar,
|
|
76
|
+
`${s.green}◇${s.reset} Starting`,
|
|
77
|
+
];
|
|
78
|
+
if (options.watching !== false) {
|
|
79
|
+
lines.push(
|
|
80
|
+
`${bar} ${s.dim}watching — client types regenerate on save${s.reset}`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
lines.push(bar);
|
|
84
|
+
return `${lines.join("\n")}\n`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* One service URL line (Console / MCP after bind).
|
|
89
|
+
*
|
|
90
|
+
* @param label - Surface name
|
|
91
|
+
* @param url - Absolute URL
|
|
92
|
+
* @param color - Color on/off
|
|
93
|
+
*/
|
|
94
|
+
export function formatServiceLine(
|
|
95
|
+
label: string,
|
|
96
|
+
url: string,
|
|
97
|
+
color: boolean = termColorEnabled(),
|
|
98
|
+
): string {
|
|
99
|
+
const s = termStyle(color);
|
|
100
|
+
const pad = label.padEnd(7);
|
|
101
|
+
return `${s.dim}│${s.reset} ${s.dim}${pad}${s.reset} ${s.cyan}${url}${s.reset}\n`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* App child ready line (`bun --hot` soft reload).
|
|
106
|
+
*
|
|
107
|
+
* @param url - App base URL
|
|
108
|
+
* @param color - Color on/off
|
|
109
|
+
*/
|
|
110
|
+
export function formatAppReadyLine(
|
|
111
|
+
url: string,
|
|
112
|
+
color: boolean = termColorEnabled(),
|
|
113
|
+
): string {
|
|
114
|
+
const s = termStyle(color);
|
|
115
|
+
return `${s.green}●${s.reset} ${s.dim}App${s.reset} ${s.cyan}${url}${s.reset}\n`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Quiet status line (regen, stack up, …).
|
|
120
|
+
*
|
|
121
|
+
* @param message - Status text
|
|
122
|
+
* @param color - Color on/off
|
|
123
|
+
*/
|
|
124
|
+
export function formatStatusLine(
|
|
125
|
+
message: string,
|
|
126
|
+
color: boolean = termColorEnabled(),
|
|
127
|
+
): string {
|
|
128
|
+
const s = termStyle(color);
|
|
129
|
+
return `${s.dim}│${s.reset} ${s.dim}${message}${s.reset}\n`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* First-admin claim code note (clack `note`-style box).
|
|
134
|
+
*
|
|
135
|
+
* @param code - Hex claim code
|
|
136
|
+
* @param color - Color on/off
|
|
137
|
+
*/
|
|
138
|
+
export function formatClaimNote(
|
|
139
|
+
code: string,
|
|
140
|
+
color: boolean = termColorEnabled(),
|
|
141
|
+
): string {
|
|
142
|
+
const s = termStyle(color);
|
|
143
|
+
const bar = `${s.dim}│${s.reset}`;
|
|
144
|
+
const title = "Claim code";
|
|
145
|
+
const hint = "expires in 30 min";
|
|
146
|
+
const ownership = "Whoever can read this log already owns the server.";
|
|
147
|
+
const lines = [
|
|
148
|
+
"",
|
|
149
|
+
`${s.magenta}◆${s.reset} ${s.bold}${title}${s.reset} ${s.dim}${hint}${s.reset}`,
|
|
150
|
+
bar,
|
|
151
|
+
`${bar} ${s.bold}${code}${s.reset}`,
|
|
152
|
+
bar,
|
|
153
|
+
`${bar} ${s.dim}${ownership}${s.reset}`,
|
|
154
|
+
`${s.dim}└${s.reset}`,
|
|
155
|
+
"",
|
|
156
|
+
];
|
|
157
|
+
return `${lines.join("\n")}\n`;
|
|
158
|
+
}
|