Introduction

DeepSeek Harness (DSH) agents, when handling front-end styles, design specifications, or performing accessibility (WCAG) assessments, often need to manipulate color data directly. Relying on network lookups or invoking external libraries not only increases latency but can also be constrained by the network environment. dsh-color is a local color toolbox designed for DSH. It embeds color processing capabilities into the plugin, completing complex color calculations without any runtime dependencies or network requests.

What It Is

dsh-color is a color utility library implemented with pure mathematics, maintained by TYEclipse. It focuses on parsing and converting CSS color formats, calculating WCAG 2.0 contrast, looking up CSS color names, and generating harmonious color schemes. All calculations are performed locally and do not cause side effects.

Core Features

The plugin provides the following core capabilities:

  1. Color Parsing and Conversion
    Supports parsing arbitrary CSS colors (including hex, rgb, hsl, hwb, CSS named colors) into specified formats. Supports Hex shorthand/full forms (3/4/6/8 digits), traditional and modern RGB syntax, angle units, and transparency handling.

  2. WCAG Contrast Evaluation
    Based on the WCAG 2.x standard, calculates the contrast ratio between two colors and provides pass/fail verdicts for AA/AAA levels. Supports threshold checks for normal text and large text (≥18pt or ≥14pt bold).

  3. Color Name Lookup
    Supports finding CSS color names by name substring or exact value, and returns the corresponding hex, rgb, hsl, and lightness values.

  4. Color Scheme Generation
    Generates harmonious color combinations based on a base color, including complementary, analogous, triadic, split-complementary, tetradic, square, and monochromatic schemes.

  5. Color Adjustment
    Supports lightening, darkening, saturating, desaturating, or rotating the hue of a color. Results also support hex/rgb/hsl output.

Installation and Activation

Installing this plugin requires specifying a DSH profile (for example, web), because DSH itself does not have a default profile.

dsh plugin --profile web add github:TYEclipse/dsh-color

Typical Usage

After installation, you can directly invoke the following commands in a DSH session:

Color Conversion

// 将颜色名称转换为多种格式
convert_color("rebeccapurple")
// 输出: hex #663399, rgb(102, 51, 153), hsl(270, 50%, 40%), hwb(270 20% 40%)

// 指定输出格式
convert_color("#ff000080", format: "hex")
// 输出: #ff000080 (alpha 保留)

Contrast Calculation

// 计算 CSS 颜色和 hex 颜色的对比度
contrast_ratio("#777777", "#ffffff")
// 输出: ratio 4.48 — fail for normal text, AA for large text

contrast_ratio("white", "hsl(0, 100%, 50%)")
// 输出: ratio 4.0 — AA for large text only

Color Schemes

// 生成互补色方案
color_scheme("#336699", type: "triadic")

// 生成类似色方案,数量为 5
color_scheme("#ff0000", type: "analogous", count: 5)

// 生成单色方案,数量为 4
color_scheme("#336699", type: "monochromatic", count: 4)

Color Adjustment

// 将颜色变亮 25%
adjust_color("#336699", op: "lighten", amount: 25)

// 将红色色相旋转 120 度(变绿)
adjust_color("#ff0000", op: "hue", amount: 120)

Usage Notes and Precautions

  • Alpha channel handling: In all conversions, the alpha channel is preserved. When the alpha value is less than 1, hex output is automatically converted to the 8-digit format (with alpha).
  • WCAG mathematical details: Contrast calculation uses relative luminance (based on sRGB linearization), with the formula (L1+0.05)/(L2+0.05). Thresholds are set as: normal text AA 4.5 / AAA 7; large text AA 3 / AAA 4.5.
  • Color adjustment mechanism: Lightness/saturation adjustments are applied as percentage-point offsets (0-100) relative to channel values, with out-of-range values clipped; hue rotation supports arbitrary angles.
  • Compatibility: Supports 148 CSS color names and the transparent keyword.
  • Dependencies: Has zero runtime dependencies, uses pure mathematical calculations, and complies with modern CSS behavior (such as clipping out-of-range values).

Conclusion

dsh-color provides DSH agents with robust local color-processing capabilities, enabling them to complete tasks from simple format conversions to complex design-specification validation without network access. All features are open source under the MIT license and are suitable for use in a variety of automation scenarios involving visual design.