Skip to content

feat: ship an agent harness with theme and color tools - #113

Merged
tenphi merged 3 commits into
mainfrom
claude/clever-lovelace-wz2ua2
Nov 12, 2026
Merged

tenphi merged 3 commits into
mainfrom
claude/clever-lovelace-wz2ua2

Conversation

@tenphi

@tenphi tenphi commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

What

Glaze now ships a harness for coding agents (Claude Code, Codex) in harness/, inside the npm package. A project that depends on Glaze and uses harnesspm (@tenphi/harnesspm) gets it on install:

Unit What the consumer gets
📏 Rule glaze:rules/colors (always-on, 0.8 KiB) Themes are the source of colors; never hand-write dark / HC values; use the skill; check with the tools.
📚 Docs glaze:docs An index of docs/ (all 19 pages, .md and .mdx, titled by frontmatter) pointing at the installed version.
🧭 Skill glaze-theme The workflow from Designing a palette: which page to read, authoring order, checking, exporting.
🔧 Script glaze:inspect Resolves a theme or palette in light, dark, light HC, dark HC and measures every color that has a base. Each contrast floor gets ✓ / ✗; Glaze's own warnings are listed. Exits 1 on a miss. 🆕 --color <part> and --theme <name> narrow a large palette.
🔧 Script glaze:color 🆕 Resolves one color without a theme file: its value, hue, saturation and tone in all four schemes, and with --base / --contrast its WCAG and APCA contrast on that base in each scheme.
🔧 Script glaze:contrast WCAG ratio and APCA Lc of a text color on a background, with the presets it passes.
📦 Export @tenphi/glaze/harness/measure 🆕 The measuring module behind the tools, public with types, so other harnesses (UI Kit's uikit:tokens) build on it.

Scripts run only in projects that trust the package ("trust": { "@tenphi/glaze": true } in harnesspm.json).

Why

The methodology checklist asks people to verify "rendered WCAG/APCA results" in every scheme and "no unexplained warnings". An agent can't see a rendered page, so today it writes a throwaway script or guesses. glaze:inspect turns that checklist item into one command, and its numbers are the solver's own.

The two new tools come from what the pilot agent runs showed:

  • 🔁 Edit-and-rerun loop. To try a color, the Glaze pilot agent edited the theme file and re-ran glaze:inspect each time. glaze:color answers "what tone is this brand color, and where does Glaze put it on this surface?" in one call, before any edit.
  • 🔢 Four calls per pair. The UI Kit pilot agent called glaze:contrast four times, once per scheme, with copied hex values. glaze:color <color> --base <surface> measures all four schemes at once (the base adapts like glaze.color(<base>)).
  • 📜 Too much output. UI Kit's palette has 164 colors in 8 themes: a full glaze:inspect prints 339 lines. --color brand --theme default prints only what the agent asked about.

How it looks

What AGENTS.md gets in a consumer project:

## @tenphi/glaze 3.0.1

### Glaze colors (glaze:rules/colors)

#### Where colors come from
- Colors that adapt to light, dark and high contrast come from a Glaze theme or palette …
- Do not write dark or high-contrast values by hand. …
- To create or change a theme, use the `glaze-theme` skill.

#### Checking a theme
- After you change a theme, run `glaze:inspect` on the file that defines it, and fix every ✗ and every Glaze warning it prints. In a large palette, add `--color <part>`.
- To try one color, such as a brand color, before you add it, run `glaze:color <color> --base <surface> --contrast AA`.
- To check two literal colors, run `glaze:contrast <text> <background>`.

- Docs: node_modules/.harnesspm/docs/glaze/llms.txt (glaze:docs)
- Script: `npx harnesspm run glaze:inspect` — Resolve a theme or palette in light, dark and high contrast, and check every contrast floor (filter with --color, --theme) (glaze:scripts/inspect)
- Script: `npx harnesspm run glaze:color` — Resolve one color without a theme: its values and tone in light, dark and high contrast, and its contrast on a --base (glaze:scripts/color)
- Script: `npx harnesspm run glaze:contrast` — Measure the WCAG and APCA contrast of a text color on a background (glaze:scripts/contrast)

npx harnesspm run glaze:color '#2563eb' --base '#ffffff' --contrast AA:

role text, floor WCAG ≥ 4.5, 7 in HC

              light    dark     light HC  dark HC
color         #2563eb  #5486ed  #164eca   #6594f3
  hue         262.9    262.9    262.9     262.9
  saturation  94.7     85.2     94.7      85.2
  tone        47.6     59.6     37.4      64.7
base          #ffffff  #222222  #ffffff   #000000
  WCAG        ✓ 5.17   ✓ 4.55   ✓ 7.07    ✓ 7.07
  APCA Lc     74.9     37.1     83.7      45.7

The floor is met in all four schemes.

The color is a value (hex, rgb(), hsl(), okhsl(), okhst(), oklch()) or a glaze.color() input as JSON ('{"from":"#2563eb","tone":40}'). Floors: AA, AAA, AA-large, a ratio such as 4.5, apca:content, apca:75, or JSON. Exits 1 on a missed floor.

npx harnesspm run glaze:inspect src/palette.mjs --theme danger --color accent-text on UI Kit's palette:

Showing 3 of 164 colors.

danger (hue 23.1, saturation 100)

color                                      light    dark     light HC  dark HC
accent-selected-fill                       #f4efef  #3f2b2a  #ece7e7   #2e1c1b
  vs surface               WCAG, no floor  1.07     1.17     1.08      1.15
accent-text                                #844947  #f69691  #462423   #fccac6
  vs accent-selected-fill  WCAG ≥ 6/11     ✓ 6.06   ✓ 6.06   ✓ 11.11   ✓ 11.11
accent-text-soft                           #9d5855  #de7f7b  #703d3b   #f58f8a
  vs accent-selected-fill  WCAG ≥ 4.6/7    ✓ 4.65   ✓ 4.65   ✓ 7.07    ✓ 7.07

All 8 contrast floors are met.
  • --color keeps colors whose name contains a part (a comma list matches any part), plus the base each is measured against, so every "vs" row has its base on screen.
  • --theme keeps palette themes by name; an unknown name fails and lists the themes.
  • A filtered run prints only the Glaze warnings that name a shown color, and says how many it hid. The exit code counts the floors shown.

The measuring module, @tenphi/glaze/harness/measure

import * as g from '@tenphi/glaze';
import { inspectColor, inspectTheme, missesOf } from '@tenphi/glaze/harness/measure';

missesOf([inspectTheme(g, theme, 'default')]); // every missed floor, per scheme
inspectColor(g, '#2563eb', { base: '#ffffff', contrast: 'AA' }).schemes.dark;
  • Exports: inspectTheme, filterThemes, missesOf, inspectColor, measurePair, parseColor, formatVariant, roleOf, themesFromSnapshot, themesFromObject, kindOf, SCHEMES, WCAG_PRESETS, FORMATS.
  • ESM only. Hand-written types in measure.d.mts, checked by a new tsconfig.harness.json (without skipLibCheck) in pnpm typecheck.
  • Semver like the rest of the API. Documented in the Utilities reference ("Measuring module") and in AGENTS.md, which marks the module as public.
  • Every function takes the Glaze module first, so a caller passes the same instance its themes come from (Glaze's config lives in that instance).

Design notes

  • 🎯 Same numbers as the solver. measure.mjs uses the metric's own luminance (gamutClampedLuminance / apcaLuminanceFromLinearRgb), each variant's pastel, the floor resolved per scheme with resolveContrastForLevel (so contrastLevel and HC escalation apply), and APCA polarity from the role. roleOf mirrors resolveRoleInMap in src/resolver.ts, the one place that must stay in step with the resolver (noted in AGENTS.md). inspectColor reads a token's role and floor from its own snapshot, and a base it brought along through glaze.colorFrom().
  • 🧪 Tested against the source. Every function in measure.mjs takes the Glaze module, so src/harness.test.ts runs it on src/ (no build needed) while the CLI uses dist/. New tests: inspectColor keeps a value exact in light, measures the adapting base in every scheme, sees the solver's APCA landing (+0.5 Lc), marks an unmeetable floor (7:1 on a mid gray) and takes tokens; filterThemes; the CLI parsers; the ./harness/measure export.
  • 🪶 No new runtime dependencies. Plain .mjs, Node ≥ 20 (a TS theme module needs Node 22.18+ type stripping; JSON works everywhere).
  • 🛡️ harnesspm check in CI. @tenphi/harnesspm is a devDependency, and CI runs pnpm exec harnesspm check after the tests.
  • 📦 package.json: harness in files; the ./harness/measure export; format / format:check cover harness/**/*.{mjs,mts}. tsconfig.test.json gets allowJs, resolveJsonModule and a paths entry so the types resolve @tenphi/glaze to src/.
  • 📝 README.md "Coding agents" section, AGENTS.md harness/ table, and two minor changesets: the harness with its three tools, and the public measuring module.

Verification

  • pnpm typecheck, pnpm lint, pnpm format:check, pnpm test (879 tests), pnpm exec harnesspm check ✅ — CI green on bfcaf6a, including the new harness check step and the docs build.
  • End to end, in a fresh app: this branch packed, @tenphi/harnesspm 0.1.0 from npm, an isolated HOME, harnesspm init, trust for @tenphi/glaze, sync run as a person. ✅ Managed block (above), docs index, skill link, and allow rules for all three scripts. All three tools ran through npx harnesspm run.
  • 🤖 Live agent run on a real palette. The app's src/palette.mjs is UI Kit's palette (8 themes, 164 colors), written out as plain glaze() themes. Headless Claude Code, asked: "Our brand color is #2563eb. Add it to the app's color palette in the default theme: a brand fill for primary buttons with readable text on it, and a brand color for links on the page surface. All text must stay readable (WCAG AA) in light, dark and high contrast." No mention of harnesspm or the tools. What it did, in 12 turns (41 s):
    1. Loaded the glaze-theme skill.
    2. Ran glaze:color '#2563eb' and glaze:color '#2563eb' --base '#ffffff' --contrast AA before editing anything, then read the color-definitions reference from the docs index.
    3. Edited the theme once: brand-fill (from: '#2563eb', mode: 'fixed', contrast: 'AA' against a fixed brand-fill-text), brand-text (from: '#2563eb', base: 'surface', contrast: 'AA'), both pastel: false to keep the brand's chroma.
    4. Checked with glaze:inspect src/palette.mjs --color brand --theme default, then the full palette before and after: 308 floors met, no warnings.
    • No throwaway scripts and no hand-written dark or HC values. The brand blue is exact in light, and on the button in dark too. Re-checked after the run: --color brand --theme default shows 8 of 8 floors met, the full palette 308 of 308.
  • Found on the way, for harnesspm: harnesspm why glaze:scripts/color answers "No unit" in 0.1.0 (it knows only rules and skills).

Before merging

  • ✅ @tenphi/harnesspm 0.1.0 is on npm, so the README / AGENTS.md / changeset links work.
  • After this releases, UI Kit (feat: ship a harness for coding agents, with uikit:colors cube-js/cube-ui-kit#1643) swaps its canary pin for the release, and uikit:tokens / its src/harness.test.ts can import @tenphi/glaze/harness/measure instead of the file path.
  • The harness does nothing in projects that don't use harnesspm; harness/ adds about 43 KB (uncompressed) to the package.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV

Projects that use Glaze through harnesspm get a short rule, the docs
index, a glaze-theme skill and two tools: glaze:inspect resolves a
theme or palette in all four schemes and checks every contrast floor
the way the solver measures it, and glaze:contrast measures two colors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7GamurMRrRt4fBQ4Zy
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📦 Snapshot release

Published 0.0.0-snapshot.f15393d.

pnpm add @tenphi/[email protected]

…export

- glaze:color resolves one color without a theme file: its value, hue,
  saturation and tone in all four schemes, and with --base / --contrast its
  WCAG and APCA contrast on that base in each scheme.
- glaze:inspect takes --color <part> and --theme <name> to narrow a large
  palette; bases of shown colors stay, and only their warnings print.
- The measuring module is public as @tenphi/glaze/harness/measure, with
  hand-written types checked by tsconfig.harness.json.
- CI runs `harnesspm check`; @tenphi/harnesspm is a devDependency.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
@tenphi tenphi changed the title feat: ship an agent harness with theme inspection tools feat: ship an agent harness with theme and color tools Nov 12, 2026
@tenphi
tenphi marked this pull request as ready for review November 12, 2026 14:08
@tenphi
tenphi merged commit fc2c517 into main Nov 12, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 12, 2026

This branch was previously deployed

1 inactive deployment
release — bfcaf6af Deployed Nov 12, 2026 by tenphi via Build & snapshot release #303
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants