Explorar o código

chore: delete unused util/color module (#27331)

Kit Langton hai 3 meses
pai
achega
bebe5442a5

+ 0 - 19
packages/opencode/src/util/color.ts

@@ -1,19 +0,0 @@
-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 * as Color from "./color"

+ 1 - 15
packages/opencode/test/config/agent-color.test.ts

@@ -1,9 +1,8 @@
-import { test, expect } from "bun:test"
+import { expect } from "bun:test"
 import { Effect, Layer } from "effect"
 import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
 import { Config } from "@/config/config"
 import { Agent as AgentSvc } from "../../src/agent/agent"
-import { Color } from "@/util/color"
 import { testEffect } from "../lib/effect"
 
 const it = testEffect(Layer.mergeAll(Config.defaultLayer, AgentSvc.defaultLayer, CrossSpawnSpawner.defaultLayer))
@@ -46,16 +45,3 @@ it.instance(
     },
   },
 )
-
-test("Color.hexToAnsiBold converts valid hex to ANSI", () => {
-  const result = Color.hexToAnsiBold("#FFA500")
-  expect(result).toBe("\x1b[38;2;255;165;0m\x1b[1m")
-})
-
-test("Color.hexToAnsiBold returns undefined for invalid hex", () => {
-  expect(Color.hexToAnsiBold(undefined)).toBeUndefined()
-  expect(Color.hexToAnsiBold("")).toBeUndefined()
-  expect(Color.hexToAnsiBold("#FFF")).toBeUndefined()
-  expect(Color.hexToAnsiBold("FFA500")).toBeUndefined()
-  expect(Color.hexToAnsiBold("#GGGGGG")).toBeUndefined()
-})