@vellumai/cli 0.4.46 → 0.4.49
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 +7 -9
- package/package.json +1 -1
- package/src/adapters/install.sh +6 -6
- package/src/commands/clean.ts +11 -6
- package/src/commands/client.ts +5 -13
- package/src/commands/hatch.ts +8 -20
- package/src/commands/ps.ts +21 -3
- package/src/commands/recover.ts +1 -1
- package/src/commands/retire.ts +41 -2
- package/src/commands/setup.ts +172 -0
- package/src/commands/sleep.ts +1 -1
- package/src/commands/wake.ts +2 -2
- package/src/components/DefaultMainScreen.tsx +160 -19
- package/src/components/TextInput.tsx +159 -12
- package/src/index.ts +3 -0
- package/src/lib/assistant-config.ts +1 -6
- package/src/lib/constants.ts +7 -1
- package/src/lib/docker.ts +54 -6
- package/src/lib/doctor-client.ts +1 -1
- package/src/lib/gcp.ts +1 -1
- package/src/lib/http-client.ts +1 -2
- package/src/lib/input-history.ts +44 -0
- package/src/lib/local.ts +160 -161
- package/src/lib/orphan-detection.ts +13 -3
- package/src/lib/process.ts +3 -1
- package/src/lib/terminal-capabilities.ts +124 -0
- package/src/lib/xdg-log.ts +2 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal capability detection module.
|
|
3
|
+
*
|
|
4
|
+
* Detects color support, unicode availability, and terminal dimensions
|
|
5
|
+
* by inspecting TERM, COLORTERM, NO_COLOR, and related environment
|
|
6
|
+
* variables. Designed to enable graceful degradation on dumb terminals
|
|
7
|
+
* and constrained environments (e.g. SSH to a Raspberry Pi).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type ColorLevel = "none" | "basic" | "256" | "truecolor";
|
|
11
|
+
|
|
12
|
+
export interface TerminalCapabilities {
|
|
13
|
+
/** Detected color support level */
|
|
14
|
+
colorLevel: ColorLevel;
|
|
15
|
+
/** Whether the terminal likely supports unicode glyphs */
|
|
16
|
+
unicodeSupported: boolean;
|
|
17
|
+
/** Current terminal width in columns (falls back to 80) */
|
|
18
|
+
columns: number;
|
|
19
|
+
/** Current terminal rows (falls back to 24) */
|
|
20
|
+
rows: number;
|
|
21
|
+
/** True when TERM=dumb — indicates a terminal with no cursor addressing */
|
|
22
|
+
isDumb: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Detect the color support level from environment variables.
|
|
27
|
+
*
|
|
28
|
+
* Precedence (highest to lowest):
|
|
29
|
+
* 1. NO_COLOR or TERM=dumb → "none"
|
|
30
|
+
* 2. COLORTERM=truecolor / 24bit → "truecolor"
|
|
31
|
+
* 3. TERM contains "256color" → "256"
|
|
32
|
+
* 4. Any other interactive terminal → "basic"
|
|
33
|
+
* 5. Non-TTY → "none"
|
|
34
|
+
*/
|
|
35
|
+
function detectColorLevel(env: NodeJS.ProcessEnv): ColorLevel {
|
|
36
|
+
// NO_COLOR spec: https://no-color.org/
|
|
37
|
+
if (env.NO_COLOR !== undefined) return "none";
|
|
38
|
+
|
|
39
|
+
const term = (env.TERM ?? "").toLowerCase();
|
|
40
|
+
if (term === "dumb") return "none";
|
|
41
|
+
|
|
42
|
+
const colorterm = (env.COLORTERM ?? "").toLowerCase();
|
|
43
|
+
|
|
44
|
+
if (colorterm === "truecolor" || colorterm === "24bit") return "truecolor";
|
|
45
|
+
if (term.includes("256color")) return "256";
|
|
46
|
+
|
|
47
|
+
// If we have a TERM value at all, assume basic color support
|
|
48
|
+
if (term.length > 0) return "basic";
|
|
49
|
+
|
|
50
|
+
// Fallback: if stdout is a TTY, assume basic
|
|
51
|
+
if (process.stdout.isTTY) return "basic";
|
|
52
|
+
|
|
53
|
+
return "none";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Heuristic for unicode support.
|
|
58
|
+
*
|
|
59
|
+
* Checks LANG / LC_ALL / LC_CTYPE for UTF-8. Falls back to false on
|
|
60
|
+
* dumb terminals since many dumb terminal emulators lack glyph support.
|
|
61
|
+
*/
|
|
62
|
+
function detectUnicode(env: NodeJS.ProcessEnv, isDumb: boolean): boolean {
|
|
63
|
+
if (isDumb) return false;
|
|
64
|
+
|
|
65
|
+
const locale = (env.LC_ALL ?? env.LC_CTYPE ?? env.LANG ?? "").toLowerCase();
|
|
66
|
+
|
|
67
|
+
return locale.includes("utf-8") || locale.includes("utf8");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Detect terminal capabilities from the current process environment.
|
|
72
|
+
*
|
|
73
|
+
* The result is a plain object (no singletons) so tests can call this
|
|
74
|
+
* with a mocked env if needed.
|
|
75
|
+
*/
|
|
76
|
+
export function detectCapabilities(
|
|
77
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
78
|
+
): TerminalCapabilities {
|
|
79
|
+
const term = (env.TERM ?? "").toLowerCase();
|
|
80
|
+
const isDumb = term === "dumb";
|
|
81
|
+
const colorLevel = detectColorLevel(env);
|
|
82
|
+
const unicodeSupported = detectUnicode(env, isDumb);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
colorLevel,
|
|
86
|
+
unicodeSupported,
|
|
87
|
+
columns: process.stdout.columns || 80,
|
|
88
|
+
rows: process.stdout.rows || 24,
|
|
89
|
+
isDumb,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Lazily-cached capabilities for the current process. */
|
|
94
|
+
let _cached: TerminalCapabilities | undefined;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Return (and cache) the terminal capabilities for the running process.
|
|
98
|
+
*
|
|
99
|
+
* Safe to call multiple times — subsequent calls return the cached
|
|
100
|
+
* result. Use `detectCapabilities()` directly if you need a fresh read
|
|
101
|
+
* (e.g. after a terminal resize).
|
|
102
|
+
*/
|
|
103
|
+
export function getTerminalCapabilities(): TerminalCapabilities {
|
|
104
|
+
if (!_cached) {
|
|
105
|
+
_cached = detectCapabilities();
|
|
106
|
+
}
|
|
107
|
+
return _cached;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── Convenience helpers ──────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
/** True when colors should be used (any level above "none"). */
|
|
113
|
+
export function supportsColor(): boolean {
|
|
114
|
+
return getTerminalCapabilities().colorLevel !== "none";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Return `fancy` when unicode is supported, otherwise `fallback`.
|
|
119
|
+
*
|
|
120
|
+
* Example: `unicodeOrFallback("🟢", "[ok]")`
|
|
121
|
+
*/
|
|
122
|
+
export function unicodeOrFallback(fancy: string, fallback: string): string {
|
|
123
|
+
return getTerminalCapabilities().unicodeSupported ? fancy : fallback;
|
|
124
|
+
}
|
package/src/lib/xdg-log.ts
CHANGED
|
@@ -49,14 +49,14 @@ export function resetLogFile(name: string): void {
|
|
|
49
49
|
/**
|
|
50
50
|
* Copy the current log file into `destDir` with a timestamped name so that
|
|
51
51
|
* previous session logs are preserved for debugging. No-op when the source
|
|
52
|
-
* file is missing or empty.
|
|
52
|
+
* file is missing or empty, or when `destDir` does not already exist.
|
|
53
53
|
*/
|
|
54
54
|
export function archiveLogFile(name: string, destDir: string): void {
|
|
55
55
|
try {
|
|
56
|
+
if (!existsSync(destDir)) return;
|
|
56
57
|
const srcPath = join(getLogDir(), name);
|
|
57
58
|
if (!existsSync(srcPath) || statSync(srcPath).size === 0) return;
|
|
58
59
|
|
|
59
|
-
mkdirSync(destDir, { recursive: true });
|
|
60
60
|
const ts = new Date().toISOString().replace(/[:.]/g, "-");
|
|
61
61
|
const base = name.replace(/\.log$/, "");
|
|
62
62
|
copyFileSync(srcPath, join(destDir, `${base}-${ts}.log`));
|