the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli: handle light terminal theme

+50 -1
+50 -1
apps/cli/src/theme.ts
··· 1 1 import chalk from "chalk"; 2 + import { execSync } from "child_process"; 3 + import * as fs from "fs"; 4 + 5 + function detectLightTerminal(): boolean { 6 + // VS Code terminal 7 + const vscodeTheme = process.env.VSCODE_THEME_KIND; 8 + if (vscodeTheme) { 9 + return vscodeTheme === "vscode-light" || vscodeTheme === "vscode-high-contrast-light"; 10 + } 11 + 12 + // COLORFGBG — set by xterm, iTerm2, etc. ("fg;bg", bg >= 8 = light) 13 + const colorfgbg = process.env.COLORFGBG; 14 + if (colorfgbg) { 15 + const parts = colorfgbg.split(";"); 16 + const bg = parseInt(parts[parts.length - 1] ?? "", 10); 17 + if (!isNaN(bg)) return bg >= 8; 18 + } 19 + 20 + // OSC 11 background color query — works with Apple Terminal, iTerm2, etc. 21 + // stty is redirected from /dev/tty explicitly because execSync pipes stdio, 22 + // which means stty would otherwise fail to find the terminal. 23 + if (process.stdout.isTTY) { 24 + try { 25 + const savedState = execSync("stty -g </dev/tty 2>/dev/null", { encoding: "utf8" }).trim(); 26 + try { 27 + const tty = fs.openSync("/dev/tty", "r+"); 28 + execSync("stty raw -echo min 0 time 5 </dev/tty 2>/dev/null"); 29 + fs.writeSync(tty, "\x1b]11;?\x07"); 30 + const buf = Buffer.alloc(64); 31 + const n = fs.readSync(tty, buf, 0, 64, null); 32 + fs.closeSync(tty); 33 + const resp = buf.slice(0, n).toString(); 34 + const m = resp.match(/rgb:([0-9a-f]+)\/([0-9a-f]+)\/([0-9a-f]+)/i); 35 + if (m?.[1] && m[2] && m[3]) { 36 + // Components can be 2 or 4 hex digits; normalize to 0-255 37 + const norm = (h: string) => parseInt(h.slice(0, 2), 16); 38 + const r = norm(m[1]), g = norm(m[2]), b = norm(m[3]); 39 + return 0.299 * r + 0.587 * g + 0.114 * b > 127; 40 + } 41 + } finally { 42 + execSync(`stty ${savedState} </dev/tty 2>/dev/null`); 43 + } 44 + } catch {} 45 + } 46 + 47 + return false; 48 + } 49 + 50 + const isLightTerminal = detectLightTerminal(); 2 51 3 52 export const c = { 4 53 primary: (s: string | number) => chalk.rgb(0, 232, 198)(s), 5 54 secondary: (s: string | number) => chalk.rgb(0, 198, 232)(s), 6 55 accent: (s: string | number) => chalk.rgb(130, 100, 255)(s), 7 56 highlight: (s: string | number) => chalk.rgb(100, 232, 130)(s), 8 - muted: (s: string | number) => chalk.rgb(200, 210, 220)(s), 57 + muted: (s: string | number) => isLightTerminal ? chalk.black(s) : chalk.rgb(200, 210, 220)(s), 9 58 link: (s: string | number) => chalk.rgb(255, 160, 100)(s), 10 59 sky: (s: string | number) => chalk.rgb(0, 210, 255)(s), 11 60 error: (s: string | number) => chalk.rgb(255, 100, 100)(s),