omp-conductor 0.16.2 → 0.17.0
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 +38 -4
- package/REFERENCE.md +17 -11
- package/package.json +2 -1
- package/src/clack-ui.ts +83 -0
- package/src/command-manifest.ts +16 -7
- package/src/commands/arm.ts +7 -2
- package/src/commands/decision.ts +17 -7
- package/src/commands/doctor.ts +18 -1
- package/src/commands/hold.ts +9 -7
- package/src/commands/ledger.ts +25 -4
- package/src/commands/setup.ts +61 -10
- package/src/commands/stats.ts +9 -5
- package/src/commands/status.ts +32 -5
- package/src/commands/tail.ts +13 -1
- package/src/commands/watch.ts +16 -7
- package/src/fleet.ts +55 -15
- package/src/orchestrator-tick.ts +46 -7
- package/src/privileged.ts +3 -0
- package/src/setup-answers.ts +135 -0
- package/src/setup-install.ts +2 -0
- package/src/setup-probe.ts +1 -0
- package/src/setup-wizard.ts +120 -29
- package/src/ui/progress.ts +32 -0
- package/src/ui/style.ts +11 -0
- package/src/wizard-ui.ts +14 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Whether the CLI owns an interactive terminal rather than a pipe or plain-UI session. */
|
|
2
|
+
export function interactiveUi(): boolean {
|
|
3
|
+
return Boolean(
|
|
4
|
+
process.stdin.isTTY &&
|
|
5
|
+
process.stdout.isTTY &&
|
|
6
|
+
!process.env.OMP_CONDUCTOR_PLAIN_UI,
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Run one long, silent operation with safe Clack progress on an interactive TTY. */
|
|
11
|
+
export async function withProgress<T>(
|
|
12
|
+
message: string,
|
|
13
|
+
success: string,
|
|
14
|
+
operation: () => Promise<T>,
|
|
15
|
+
options: { plainMessage?: boolean } = {},
|
|
16
|
+
): Promise<T> {
|
|
17
|
+
if (!interactiveUi()) {
|
|
18
|
+
if (options.plainMessage) process.stdout.write(`${message}\n`);
|
|
19
|
+
return operation();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { log } = await import("@clack/prompts");
|
|
23
|
+
log.step(message);
|
|
24
|
+
try {
|
|
25
|
+
const result = await operation();
|
|
26
|
+
log.success(success);
|
|
27
|
+
return result;
|
|
28
|
+
} catch (err) {
|
|
29
|
+
log.error(`${message} failed`);
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/ui/style.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
|
|
3
|
+
function styled(format: Parameters<typeof styleText>[0], text: string): string {
|
|
4
|
+
return process.stdout.isTTY ? styleText(format, text) : text;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const heading = (text: string): string => styled(["bold", "cyan"], text);
|
|
8
|
+
export const ok = (text: string): string => styled("green", text);
|
|
9
|
+
export const warn = (text: string): string => styled("yellow", text);
|
|
10
|
+
export const fail = (text: string): string => styled("red", text);
|
|
11
|
+
export const dim = (text: string): string => styled("dim", text);
|
package/src/wizard-ui.ts
CHANGED
|
@@ -24,6 +24,15 @@
|
|
|
24
24
|
* (`Cancelled`). The terminal UI guarantees the readline interface is closed on
|
|
25
25
|
* every exit path so the verb cannot hang the terminal.
|
|
26
26
|
*/
|
|
27
|
+
export interface PromptOptions {
|
|
28
|
+
/** Stable answer-file key. This is a permanent CLI API, not display copy. */
|
|
29
|
+
key: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SelectOptions extends PromptOptions {
|
|
33
|
+
initialIndex?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
export interface WizardUi {
|
|
28
37
|
notify(message: string, type?: "info" | "warning" | "error"): void;
|
|
29
38
|
/**
|
|
@@ -32,17 +41,17 @@ export interface WizardUi {
|
|
|
32
41
|
* `Cancelled` and abandons the run. Collapsing the two is how Ctrl-C at a
|
|
33
42
|
* confirm used to record a silent "no" and carry on to the next question.
|
|
34
43
|
*/
|
|
35
|
-
confirm(title: string, message: string): Promise<boolean | undefined>;
|
|
44
|
+
confirm(title: string, message: string, promptOptions: PromptOptions): Promise<boolean | undefined>;
|
|
36
45
|
/** Single-line text prompt. `undefined` dismisses it; an empty submit accepts
|
|
37
46
|
* the placeholder. */
|
|
38
|
-
input(title: string, placeholder
|
|
47
|
+
input(title: string, placeholder: string | undefined, promptOptions: PromptOptions): Promise<string | undefined>;
|
|
39
48
|
/** Single-choice list. On an interactive TTY the current option is rendered
|
|
40
49
|
* inline and moved with ↑/↓ or j/k; on a pipe it stays the numbered wall.
|
|
41
50
|
* Resolves the chosen option's label, or `undefined` when dismissed. */
|
|
42
51
|
select(
|
|
43
52
|
title: string,
|
|
44
53
|
options: { label: string; description?: string }[],
|
|
45
|
-
dialogOptions
|
|
54
|
+
dialogOptions: SelectOptions,
|
|
46
55
|
): Promise<string | undefined>;
|
|
47
56
|
}
|
|
48
57
|
|
|
@@ -83,8 +92,8 @@ import type { Readable, Writable } from "node:stream";
|
|
|
83
92
|
* rather than only through a spawned CLI; production callers pass nothing.
|
|
84
93
|
*/
|
|
85
94
|
export interface TerminalUi extends WizardUi {
|
|
86
|
-
/** Releases stdin
|
|
87
|
-
close(): void;
|
|
95
|
+
/** Releases stdin; interactive drivers may render the outcome message. Idempotent. */
|
|
96
|
+
close(message?: string): void;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
export function terminalUi(io: { input?: Readable; output?: Writable } = {}): TerminalUi {
|