TYEclipse/dsh-color
DeepSeek Harness (dsh) 的颜色转换工具箱:解析/转换任意 CSS 颜色(十六进制、rgb、hsl、hwb、命名颜色),支持 WCAG 对比度及 AA/AAA 判定,命名颜色查询——零运行时依赖,纯数学实现
项目介绍Project Overview
dsh-color 是 DeepSeek Harness 的本地色彩工具箱,零依赖、无网络调用。提供 5 个工具:convert_color 在 hex/rgb/hsl/hwb 及 148 个 CSS 命名色间互转,保留 alpha;contrast_ratio 按 WCAG 2.x 计算对比度并给出 AA/AAA 判定;color_info 支持按名称子串或精确值查找;color_scheme 从基色生成互补、类似、三分等 7 类和谐配色;adjust_color 可调亮度/饱和度/色相。通道越界按 CSS 规范截断,灰度饱和为 no-op。当需要在 LLM 流程中做配色推导、对比度校验或无副作用的色彩转换时使用;调整只能基于单色整体计算,不适合做复杂渐变插值。
dsh-color is a local color toolbox for DeepSeek Harness with zero dependencies and no network calls. It exposes five tools: convert_color, which parses any CSS color (hex, rgb/hsl/hwb, 148 named colors) and outputs all formats while preserving alpha; contrast_ratio, which computes WCAG 2.x contrast with AA/AAA verdicts for normal or large text; color_info, which looks up names by substring or exact value; color_scheme, which generates complementary, analogous, triadic, split-complementary, tetradic, square, and monochromatic palettes from a base color; and adjust_color, which lightens, darkens, saturates, desaturates, or hue-rotates a color. Use it when a pipeline needs palette generation, contrast checks, or side-effect-free color math. Channels are clamped per modern CSS, and saturating a gray is a no-op, so downstream color math may need guarding.
请帮我了解并安装插件:【dsh-color】【https://github.com/TYEclipse/dsh-color】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add github:TYEclipse/dsh-color
把 TYEclipse/dsh-color 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-color
Color toolbox for DeepSeek Harness (dsh): parse and convert any CSS color, evaluate WCAG contrast, look up CSS color names, generate harmonious palettes, and adjust colors.
Pure local math — zero runtime dependencies, no network, no side effects.
Tools
| Tool | Description |
|---|---|
convert_color |
Parse any CSS color (hex #rgb/#rgba/#rrggbb/#rrggbbaa, rgb()/rgba(), hsl()/hsla(), hwb(), CSS color names) and convert it to hex / rgb / hsl / hwb — or all formats at once |
contrast_ratio |
WCAG 2.x contrast ratio between two colors with AA/AAA verdicts for normal or large text (WCAG 1.4.3 thresholds) |
color_info |
CSS named-color lookup: search by name substring ("blue" → blue, blueviolet, lightblue, …) or by exact value (aqua ≡ cyan), with hex/rgb/hsl/luminance per match |
color_scheme |
Harmonious palettes from a base color: complementary, analogous (3/5), triadic, split-complementary, tetradic, square, monochromatic (2–9 shades) — every color as hex + rgb + hsl |
adjust_color |
lighten / darken / saturate / desaturate (percentage points) or hue-rotate (degrees) a color — result as hex + rgb + hsl |
Install
dsh plugin --profile web add github:TYEclipse/dsh-color
Replace web with your profile name (dsh plugin has no default profile).
Usage examples
convert_color("rebeccapurple")
→ hex #663399, rgb(102, 51, 153), hsl(270, 50%, 40%), hwb(270 20% 40%)
convert_color("#ff000080", format: "hex")
→ #ff000080 (alpha preserved)
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_info(query: "blue", limit: 5)
→ blue #0000ff, blueviolet #8a2be2, cadetblue #5f9ea0, …
color_info(query: "#00ffff", by: "value")
→ aqua, cyan (both map to #00ffff)
color_scheme("#336699", type: "triadic")
→ #336699, #993366, #669933
color_scheme("#ff0000", type: "analogous", count: 5)
→ #ff00ff, #ff0080, #ff0000, #ff8000, #ffff00
color_scheme("#336699", type: "monochromatic", count: 4)
→ #030508, #24476b, #4f8ac4, #b3cce6
adjust_color("#336699", op: "lighten", amount: 25)
→ #79a6d2
adjust_color("#ff0000", op: "hue", amount: 120)
→ #00ff00
Feature notes
- Input formats: hex shorthand/full (3/4/6/8 digits), legacy comma syntax
(
rgb(255, 0, 0)) and modern space syntax (rgb(255 0 0 / 50%)), percentages (rgb(100% 0% 0%)), angle units for hue (deg/rad/grad/turn), all 148 CSS Color Module Level 4 named colors, andtransparent. - Alpha is preserved through every conversion; hex output switches to 8-digit form only when alpha < 1.
- WCAG math: relative luminance per WCAG 2.x (sRGB linearization), ratio
(L1+0.05)/(L2+0.05), thresholds AA 4.5 / AAA 7 for normal text and AA 3 / AAA 4.5 for large text (≥18pt or ≥14pt bold). - Palette math: rotation harmonies keep the base saturation/lightness and rotate the hue by the canonical offsets (complementary +180°, triadic +120°/+240°, split-complementary +150°/+210°, tetradic +60°/+180°/+240°, square +90°/+180°/+270°); analogous is centered on the base (−30°/0/+30°, or −60°/−30°/0/+30°/+60° for 5 colors); monochromatic keeps hue/saturation and steps lightness evenly across [l−0.4, l+0.4] (clamped to [0.02, 0.98]).
- Adjustment math: lighten/darken/saturate/desaturate shift the channel by N percentage points (clamped 0–100); hue rotates by N degrees (any sign, normalized). Saturating a gray is a no-op, matching CSS filter semantics.
- Channel serialization rounds half up with a floating-point dust guard,
matching CSS serialization (e.g.
hsl(210, 100%, 50%)→rgb(0, 128, 255)). - Out-of-range channels are clamped (modern CSS behavior).
Development
pnpm install # CI=true if pnpm asks about build scripts
pnpm build # tsc → dist/
pnpm test # vitest
pnpm lint # oxlint src test
License
MIT
Small-tailqwq/dsh-deep-whale
kingOfSoySauce/dsh-liang-skin
RevolutionLA/dsh-dream-skin
Fishquito7/dsh-skill-mcp-panel
XieRW/dsh-beauty-skins
alingalingling/ui-status-label
SLin-code/dsh-custom-skin