icoa-cli 2.19.22 → 2.19.24
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/lib/colors.d.ts +15 -0
- package/dist/lib/colors.js +21 -0
- package/dist/lib/theme.js +70 -47
- package/dist/lib/ui.js +10 -5
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const c: {
|
|
2
|
+
fg: (s: string) => string;
|
|
3
|
+
muted: (s: string) => string;
|
|
4
|
+
red: (s: string) => string;
|
|
5
|
+
green: (s: string) => string;
|
|
6
|
+
yellow: (s: string) => string;
|
|
7
|
+
blue: (s: string) => string;
|
|
8
|
+
cyan: (s: string) => string;
|
|
9
|
+
orange: (s: string) => string;
|
|
10
|
+
white: (s: string) => string;
|
|
11
|
+
};
|
|
12
|
+
export declare const DARCULA_BG_HEX = "#2B2B2B";
|
|
13
|
+
export declare const DARCULA_FG_HEX = "#A9B7C6";
|
|
14
|
+
export declare const DARCULA_BG_RGB: readonly [43, 43, 43];
|
|
15
|
+
export declare const DARCULA_FG_RGB: readonly [169, 183, 198];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Darcula palette — from ICOA Terminal xterm.js theme spec.
|
|
2
|
+
// Use c.* helpers when you need brand-accurate truecolor (e.g. the orange
|
|
3
|
+
// accent #CC7832). For generic success/error/warning, chalk.green/.red/.yellow
|
|
4
|
+
// remain fine — they render as the terminal's Darcula 16-color when using an
|
|
5
|
+
// ICOA theme and as close-enough defaults elsewhere.
|
|
6
|
+
const tc = (r, g, b) => (s) => `\x1b[38;2;${r};${g};${b}m${s}\x1b[39m`;
|
|
7
|
+
export const c = {
|
|
8
|
+
fg: tc(169, 183, 198), // #A9B7C6 body text
|
|
9
|
+
muted: tc(85, 85, 85), // #555555 comments / secondary
|
|
10
|
+
red: tc(255, 107, 104), // #FF6B68 error
|
|
11
|
+
green: tc(168, 192, 35), // #A8C023 success
|
|
12
|
+
yellow: tc(214, 191, 85), // #D6BF55 warning
|
|
13
|
+
blue: tc(126, 174, 241), // #7EAEF1 link
|
|
14
|
+
cyan: tc(40, 123, 222), // #287BDE command / path
|
|
15
|
+
orange: tc(204, 120, 50), // #CC7832 brand accent
|
|
16
|
+
white: tc(255, 255, 255), // #FFFFFF highlight
|
|
17
|
+
};
|
|
18
|
+
export const DARCULA_BG_HEX = '#2B2B2B';
|
|
19
|
+
export const DARCULA_FG_HEX = '#A9B7C6';
|
|
20
|
+
export const DARCULA_BG_RGB = [43, 43, 43];
|
|
21
|
+
export const DARCULA_FG_RGB = [169, 183, 198];
|
package/dist/lib/theme.js
CHANGED
|
@@ -1,52 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Unified Darcula terminal theme — works identically on macOS Terminal.app,
|
|
2
|
+
// iTerm2, GNOME Terminal, Konsole, Windows Terminal (cmd/PowerShell/WSL).
|
|
3
|
+
//
|
|
4
|
+
// Two mechanisms are combined so every modern terminal gets the best it can:
|
|
5
|
+
//
|
|
6
|
+
// 1. OSC 10/11/12 sets the terminal's *default* fg/bg/cursor colors.
|
|
7
|
+
// Honored by iTerm2, GNOME Terminal, Konsole, Windows Terminal → lossless
|
|
8
|
+
// background, no scrollback or resize artifacts. Ignored by macOS
|
|
9
|
+
// Terminal.app.
|
|
10
|
+
//
|
|
11
|
+
// 2. SGR 38/48 + \x1b[2J paints the visible grid cells with Darcula colors.
|
|
12
|
+
// Works everywhere including Terminal.app. The known limits on Terminal.app
|
|
13
|
+
// (resize edge, scrollback of pre-launch history, copy-paste carrying bg)
|
|
14
|
+
// are protocol-level and accepted; fix path is importing a .terminal profile.
|
|
15
|
+
//
|
|
16
|
+
// Legacy cmd.exe (pre-Win10 1809) can't run Node 22 anyway, so no separate
|
|
17
|
+
// fallback path is needed.
|
|
18
|
+
const OSC_INIT = '\x1b]10;#A9B7C6\x07' + // default fg
|
|
19
|
+
'\x1b]11;#2B2B2B\x07' + // default bg
|
|
20
|
+
'\x1b]12;#A9B7C6\x07'; // cursor color
|
|
21
|
+
const OSC_RESET = '\x1b]110\x07' + // reset default fg
|
|
22
|
+
'\x1b]111\x07' + // reset default bg
|
|
23
|
+
'\x1b]112\x07'; // reset cursor color
|
|
24
|
+
const SGR_INIT = '\x1b[38;2;169;183;198m' + // fg #A9B7C6
|
|
25
|
+
'\x1b[48;2;43;43;43m' + // bg #2B2B2B
|
|
26
|
+
'\x1b[2J' + // paint grid with current bg
|
|
27
|
+
'\x1b[H'; // cursor home
|
|
28
|
+
const SGR_RESET = '\x1b[0m\x1b[2J\x1b[H';
|
|
29
|
+
function supportsAnsi() {
|
|
30
|
+
if (!process.stdout.isTTY)
|
|
31
|
+
return false;
|
|
32
|
+
const depth = process.stdout.getColorDepth?.();
|
|
33
|
+
if (typeof depth === 'number')
|
|
34
|
+
return depth >= 8;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
// When icoa-cli runs inside the ICOA Terminal (Tauri + xterm.js), the host is
|
|
38
|
+
// already pre-themed to the exact Darcula palette we'd be setting. Every OSC
|
|
39
|
+
// and SGR we'd emit is a no-op in terms of color, but the \x1b[2J inside our
|
|
40
|
+
// init/reset sequences would clear the grid visibly. Skip the paint entirely
|
|
41
|
+
// in that environment so the banner simply appears in the shell cursor
|
|
42
|
+
// position and scrollback is preserved on exit.
|
|
43
|
+
function isIcoaTerminal() {
|
|
44
|
+
return process.env.ICOA_TERMINAL === '1';
|
|
45
|
+
}
|
|
46
|
+
let armed = false;
|
|
3
47
|
export function setTerminalTheme() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
else {
|
|
24
|
-
// Linux / Windows: ANSI escape codes
|
|
25
|
-
process.stdout.write('\x1b[0m\x1b[40m\x1b[38;2;0;255;65m\x1b[2J\x1b[H');
|
|
48
|
+
if (!supportsAnsi())
|
|
49
|
+
return;
|
|
50
|
+
if (isIcoaTerminal())
|
|
51
|
+
return; // host is already Darcula; nothing to do
|
|
52
|
+
process.stdout.write(OSC_INIT + SGR_INIT);
|
|
53
|
+
if (!armed) {
|
|
54
|
+
armed = true;
|
|
55
|
+
// Belt-and-braces cleanup on every exit path. Without these, Ctrl+C leaves
|
|
56
|
+
// the user's shell stuck with our SGR state.
|
|
57
|
+
const cleanup = () => {
|
|
58
|
+
try {
|
|
59
|
+
process.stdout.write(OSC_RESET + SGR_RESET);
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
};
|
|
63
|
+
process.on('exit', cleanup);
|
|
64
|
+
process.on('SIGINT', () => { cleanup(); process.exit(130); });
|
|
65
|
+
process.on('SIGTERM', () => { cleanup(); process.exit(143); });
|
|
66
|
+
process.on('SIGHUP', () => { cleanup(); process.exit(129); });
|
|
26
67
|
}
|
|
27
|
-
// Clear screen
|
|
28
|
-
process.stdout.write('\x1b[2J\x1b[H');
|
|
29
68
|
}
|
|
30
69
|
export function resetTerminalTheme() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
tell application "Terminal"
|
|
37
|
-
set bg to {65535, 65535, 65535}
|
|
38
|
-
set fg to {0, 0, 0}
|
|
39
|
-
set background color of selected tab of front window to bg
|
|
40
|
-
set normal text color of selected tab of front window to fg
|
|
41
|
-
set cursor color of selected tab of front window to fg
|
|
42
|
-
end tell
|
|
43
|
-
'`, { stdio: 'ignore' });
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
process.stdout.write('\x1b[0m\x1b[2J\x1b[H');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
process.stdout.write('\x1b[0m\x1b[2J\x1b[H');
|
|
51
|
-
}
|
|
70
|
+
if (!supportsAnsi())
|
|
71
|
+
return;
|
|
72
|
+
if (isIcoaTerminal())
|
|
73
|
+
return; // nothing to undo
|
|
74
|
+
process.stdout.write(OSC_RESET + SGR_RESET);
|
|
52
75
|
}
|
package/dist/lib/ui.js
CHANGED
|
@@ -3,18 +3,23 @@ import Table from 'cli-table3';
|
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
import { Marked } from 'marked';
|
|
5
5
|
import { markedTerminal } from 'marked-terminal';
|
|
6
|
+
import { c } from './colors.js';
|
|
6
7
|
const marked = new Marked(markedTerminal());
|
|
8
|
+
// Wrap the message body in explicit Darcula fg (#A9B7C6). Without this,
|
|
9
|
+
// chalk.green('✓ ') emits \x1b[39m at the end and the unstyled msg falls
|
|
10
|
+
// back to the terminal's profile fg — which is black on macOS Terminal.app
|
|
11
|
+
// default, invisible on our forced #2B2B2B background.
|
|
7
12
|
export function printSuccess(msg) {
|
|
8
|
-
console.log(chalk.green('✓ ') + msg);
|
|
13
|
+
console.log(chalk.green('✓ ') + c.fg(msg));
|
|
9
14
|
}
|
|
10
15
|
export function printError(msg) {
|
|
11
|
-
console.log(chalk.red('✗ ') + msg);
|
|
16
|
+
console.log(chalk.red('✗ ') + c.fg(msg));
|
|
12
17
|
}
|
|
13
18
|
export function printWarning(msg) {
|
|
14
|
-
console.log(chalk.yellow('⚠ ') + msg);
|
|
19
|
+
console.log(chalk.yellow('⚠ ') + c.fg(msg));
|
|
15
20
|
}
|
|
16
21
|
export function printInfo(msg) {
|
|
17
|
-
console.log(chalk.blue('ℹ ') + msg);
|
|
22
|
+
console.log(chalk.blue('ℹ ') + c.fg(msg));
|
|
18
23
|
}
|
|
19
24
|
export function printTable(headers, rows) {
|
|
20
25
|
const table = new Table({
|
|
@@ -71,5 +76,5 @@ export function printHeader(title) {
|
|
|
71
76
|
console.log(chalk.cyan(' ' + '─'.repeat(title.length + 4)));
|
|
72
77
|
}
|
|
73
78
|
export function printKeyValue(key, value) {
|
|
74
|
-
console.log(` ${chalk.gray(key + ':')} ${value}`);
|
|
79
|
+
console.log(` ${chalk.gray(key + ':')} ${c.fg(value)}`);
|
|
75
80
|
}
|