From 27d0c711d888af53f4f47ce614b7dc60203d4808 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Wed, 15 Apr 2026 23:07:11 -0400 Subject: [PATCH] feat: unwrap Color namespace to flat exports + barrel --- packages/opencode/src/util/color.ts | 34 +++++++++---------- packages/opencode/src/util/index.ts | 1 + .../opencode/test/config/agent-color.test.ts | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/opencode/src/util/color.ts b/packages/opencode/src/util/color.ts index b96deaec47..43408295fa 100644 --- a/packages/opencode/src/util/color.ts +++ b/packages/opencode/src/util/color.ts @@ -1,19 +1,17 @@ -export namespace Color { - export function isValidHex(hex?: string): hex is string { - if (!hex) return false - return /^#[0-9a-fA-F]{6}$/.test(hex) - } - - export function hexToRgb(hex: string): { r: number; g: number; b: number } { - const r = parseInt(hex.slice(1, 3), 16) - const g = parseInt(hex.slice(3, 5), 16) - const b = parseInt(hex.slice(5, 7), 16) - return { r, g, b } - } - - export function hexToAnsiBold(hex?: string): string | undefined { - if (!isValidHex(hex)) return undefined - const { r, g, b } = hexToRgb(hex) - return `\x1b[38;2;${r};${g};${b}m\x1b[1m` - } +export function isValidHex(hex?: string): hex is string { + if (!hex) return false + return /^#[0-9a-fA-F]{6}$/.test(hex) +} + +export function hexToRgb(hex: string): { r: number; g: number; b: number } { + const r = parseInt(hex.slice(1, 3), 16) + const g = parseInt(hex.slice(3, 5), 16) + const b = parseInt(hex.slice(5, 7), 16) + return { r, g, b } +} + +export function hexToAnsiBold(hex?: string): string | undefined { + if (!isValidHex(hex)) return undefined + const { r, g, b } = hexToRgb(hex) + return `\x1b[38;2;${r};${g};${b}m\x1b[1m` } diff --git a/packages/opencode/src/util/index.ts b/packages/opencode/src/util/index.ts index 157bb8e521..f3a7f760a8 100644 --- a/packages/opencode/src/util/index.ts +++ b/packages/opencode/src/util/index.ts @@ -1 +1,2 @@ export * as Archive from "./archive" +export * as Color from "./color" diff --git a/packages/opencode/test/config/agent-color.test.ts b/packages/opencode/test/config/agent-color.test.ts index d77782354c..bfa948619b 100644 --- a/packages/opencode/test/config/agent-color.test.ts +++ b/packages/opencode/test/config/agent-color.test.ts @@ -5,7 +5,7 @@ import { provideInstance, tmpdir } from "../fixture/fixture" import { Instance } from "../../src/project/instance" import { Config } from "../../src/config" import { Agent as AgentSvc } from "../../src/agent/agent" -import { Color } from "../../src/util/color" +import { Color } from "../../src/util" import { AppRuntime } from "../../src/effect/app-runtime" const load = () => AppRuntime.runPromise(Config.Service.use((svc) => svc.get()))