Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

Knows TagAction's and TagBrush.css's next releases.

- `--remove` (remove a repeated row), `--copy`, and `--share` are TagAction commands, so `unknown-command` no longer reports them.
- `data-tag-calc="product"`, `data-tag-format`, `data-tag-theme`, and `data-tag-match` are documented TagAction attributes, and `data-layout="sticky"` (a header that stays at the top) a TagBrush.css value. `data-tone` on a `<button>` (a red Delete button) was already known.
- `broken-reference` also checks `interestfor`, the trigger of a TagBrush.css tooltip (`popover="hint"`).
- `data-tag="num"`, which TagAction puts on number columns while the page runs, is reported as `generated-markup` when it's copied into source HTML, like every `data-tag="…"`.
- The vocabulary test reads `llms.txt` from TagBrush.css and TagAction checkouts next to this repo when there are any, before the installed packages, so it checks against the unreleased guides. The TagAction demo and test pages are clean again.

## 0.1.2 (2026-11-08)

Fixes from the family agent evaluation: browser checks that work offline with every TagBrush.css build, say when a file didn't load and when they ran, and judge large text by WCAG's 3:1.
Expand Down
4 changes: 2 additions & 2 deletions ai/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Errors:
- `empty-button`, `empty-link`: buttons and links need text or `aria-label`.
- `clickable-div`: a `<div>` or `<span>` with `onclick` or `role="button"` should be a `<button>` (or an `<a href>` for navigation).
- `duplicate-id`: ids must be unique. Ids inside a `<template>` don't count; TagAction renumbers copies.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or TagAction's `--clone`.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `interestfor` (a tooltip trigger), `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or one TagAction handles (`--clone`, `--remove`, `--copy`, `--share`).
- `clone-target`: `command="--clone"` must point at a `<template>`.
- `contrast` (`--browser`): text below WCAG AA against its background in the light or dark scheme: 4.5:1, or 3:1 for large text (at least 24px, or 18.66px and bold).
- `overflow` (`--browser`): the page scrolls sideways at 360px or 1280px wide.
Expand Down
4 changes: 2 additions & 2 deletions ai/claude/tagcheck/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Errors:
- `empty-button`, `empty-link`: buttons and links need text or `aria-label`.
- `clickable-div`: a `<div>` or `<span>` with `onclick` or `role="button"` should be a `<button>` (or an `<a href>` for navigation).
- `duplicate-id`: ids must be unique. Ids inside a `<template>` don't count; TagAction renumbers copies.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or TagAction's `--clone`.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `interestfor` (a tooltip trigger), `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or one TagAction handles (`--clone`, `--remove`, `--copy`, `--share`).
- `clone-target`: `command="--clone"` must point at a `<template>`.
- `contrast` (`--browser`): text below WCAG AA against its background in the light or dark scheme: 4.5:1, or 3:1 for large text (at least 24px, or 18.66px and bold).
- `overflow` (`--browser`): the page scrolls sideways at 360px or 1280px wide.
Expand Down
4 changes: 2 additions & 2 deletions ai/cursor/tagcheck.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Errors:
- `empty-button`, `empty-link`: buttons and links need text or `aria-label`.
- `clickable-div`: a `<div>` or `<span>` with `onclick` or `role="button"` should be a `<button>` (or an `<a href>` for navigation).
- `duplicate-id`: ids must be unique. Ids inside a `<template>` don't count; TagAction renumbers copies.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or TagAction's `--clone`.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `interestfor` (a tooltip trigger), `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or one TagAction handles (`--clone`, `--remove`, `--copy`, `--share`).
- `clone-target`: `command="--clone"` must point at a `<template>`.
- `contrast` (`--browser`): text below WCAG AA against its background in the light or dark scheme: 4.5:1, or 3:1 for large text (at least 24px, or 18.66px and bold).
- `overflow` (`--browser`): the page scrolls sideways at 360px or 1280px wide.
Expand Down
4 changes: 2 additions & 2 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Errors:
- `empty-button`, `empty-link`: buttons and links need text or `aria-label`.
- `clickable-div`: a `<div>` or `<span>` with `onclick` or `role="button"` should be a `<button>` (or an `<a href>` for navigation).
- `duplicate-id`: ids must be unique. Ids inside a `<template>` don't count; TagAction renumbers copies.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or TagAction's `--clone`.
- `broken-reference`: `aria-controls`, `aria-labelledby`, `aria-describedby`, `commandfor`, `popovertarget`, `interestfor` (a tooltip trigger), `list`, `form`, and `<output for>` must name ids that exist.
- `unknown-command`: `command` must be a browser command (`show-modal`, `close`, `request-close`, `toggle-popover`, `show-popover`, `hide-popover`) or one TagAction handles (`--clone`, `--remove`, `--copy`, `--share`).
- `clone-target`: `command="--clone"` must point at a `<template>`.
- `contrast` (`--browser`): text below WCAG AA against its background in the light or dark scheme: 4.5:1, or 3:1 for large text (at least 24px, or 18.66px and bold).
- `overflow` (`--browser`): the page scrolls sideways at 360px or 1280px wide.
Expand Down
1 change: 1 addition & 0 deletions src/rules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const REFERENCES = {
'aria-describedby': null,
commandfor: null,
popovertarget: null,
interestfor: null,
list: ['input'],
form: ['button', 'fieldset', 'input', 'object', 'output', 'select', 'textarea'],
};
Expand Down
8 changes: 6 additions & 2 deletions src/vocabulary.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ export const ATTRIBUTES = {
'data-tag-remember': null,
'data-tag-time': ['relative'],
'data-tag-toc': null,
'data-tag-calc': ['product'],
'data-tag-format': null, // a currency code (USD, EUR), percent, or number
'data-tag-theme': null,
'data-tag-match': null,
'data-theme': ['light', 'dark'],
'data-layout': ['full'],
'data-layout': ['full', 'sticky'],
'data-tone': ['success', 'warning', 'error', 'info', 'neutral'],
'data-density': ['compact'],
'data-reasoning': null,
};

/** Custom commands TagAction handles (command="--…"). Built-in commands are the browser's. */
export const COMMANDS = new Set(['--clone']);
export const COMMANDS = new Set(['--clone', '--remove', '--copy', '--share']);
export const BUILT_IN_COMMANDS = new Set(['show-modal', 'close', 'request-close', 'toggle-popover', 'show-popover', 'hide-popover']);

/** Namespaces the family owns: an undocumented attribute here is a mistake. */
Expand Down
23 changes: 20 additions & 3 deletions tests/check.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test';
import { spawnSync } from 'node:child_process';
import { existsSync, readFileSync } from 'node:fs';
import { check, checkFiles, RULES } from '../src/index.mjs';
import { COMMANDS } from '../src/vocabulary.mjs';

const run = (...args) => spawnSync(process.execPath, ['bin/tagcheck.mjs', ...args], { encoding: 'utf8' });
const rules = (html) => check(html).map((p) => `${p.level}:${p.rule}`);
Expand All @@ -15,7 +16,9 @@ test.describe('static rules', () => {
const staticRules = Object.keys(RULES).filter((rule) => !['contrast', 'overflow', 'not-loaded'].includes(rule));
expect(new Set(bad.problems.map((p) => p.rule))).toEqual(new Set(staticRules));
expect(report.errors).toBe(13);
expect(report.warnings).toBe(9);
expect(report.warnings).toBe(10);
// data-tag="num" (TagAction's mark on number columns) copied from a rendered page is generated markup.
expect(bad.problems.filter((p) => p.rule === 'generated-markup').map((p) => p.message)).toContainEqual(expect.stringContaining('data-tag="num"'));
});

test('every problem has a line, column, level, rule, and message', () => {
Expand All @@ -40,6 +43,20 @@ test.describe('static rules', () => {
test('browser commands and TagAction commands are known; others are not', () => {
expect(rules(page('<button commandfor="d" command="show-modal">Open</button><button commandfor="d" command="close">Close</button><dialog id="d"></dialog>'))).toEqual([]);
expect(rules(page('<button commandfor="d" command="--open">Open</button><dialog id="d"></dialog>'))).toEqual(['error:unknown-command']);
expect(rules(page('<ul><li id="r"><input aria-label="Name"> <button commandfor="r" command="--remove" hidden>Remove</button></li></ul>'))).toEqual([]);
expect(rules(page('<input id="i" aria-label="Link" value="x" readonly><button commandfor="i" command="--copy">Copy</button><section id="s"><button commandfor="s" command="--share">Share</button></section>'))).toEqual([]);
});

test('new TagBrush.css and TagAction attributes and values are known', () => {
expect(rules(page('<header data-layout="sticky"><p>Bar</p></header><button data-tone="error">Delete</button>'))).toEqual([]);
expect(rules(page('<input id="n" aria-label="Nights" value="2"><output for="n" data-tag-calc="product" data-tag-format="USD">2</output><select data-tag-theme aria-label="Theme"></select>'))).toEqual([]);
expect(rules(page('<input id="p" aria-label="Password" type="password"><input aria-label="Confirm" type="password" data-tag-match="p">'))).toEqual([]);
expect(rules(page('<header data-layout="fixed"><p>Bar</p></header>'))).toEqual(['warning:unknown-attribute']);
});

test('an interestfor tooltip trigger must name its popover', () => {
expect(rules(page('<button interestfor="tip" aria-describedby="tip">Save</button><div popover="hint" id="tip" role="tooltip">Saves a draft</div>'))).toEqual([]);
expect(rules(page('<button interestfor="nope">Save</button>'))).toEqual(['error:broken-reference']);
});

test('popovertarget, list, and output for are checked', () => {
Expand Down Expand Up @@ -104,7 +121,7 @@ test.describe('command line', () => {
test('text output names file:line:column, level, and rule, then a summary', () => {
const { stdout } = run('tests/fixtures/bad.html');
expect(stdout).toMatch(/^tests\/fixtures\/bad\.html:12:3 {2}error {4}missing-alt/m);
expect(stdout).toMatch(/1 file checked: 13 errors, 9 warnings/);
expect(stdout).toMatch(/1 file checked: 13 errors, 10 warnings/);
});

test('--json prints a machine-readable report', () => {
Expand Down Expand Up @@ -189,7 +206,7 @@ test.describe('llms.txt contract', () => {

test('every option llms.txt mentions exists in --help', () => {
const help = run('--help').stdout;
for (const [option] of guide().matchAll(/--[a-z]+/g)) if (option !== '--clone') expect(help, option).toContain(option);
for (const [option] of guide().matchAll(/--[a-z]+/g)) if (!COMMANDS.has(option)) expect(help, option).toContain(option); // TagAction commands aren't options
});

test('generated agent files match llms.txt', () => {
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/bad.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ <h3>Skipped a level</h3>
<section data-tag-remember><details><summary>Q</summary><p>A</p></details></section>
<div class="hero flex" data-tag-sortable data-tagaction="disabled">Invented</div>
<button data-tag="copy">Copy</button>
<table><thead><tr><th data-tag="num">Total</th></tr></thead><tbody><tr><td>12</td></tr></tbody></table>
<p style="margin-top: 2rem; --gap: 1rem">Inline layout</p>
</main>
<main>Second main</main>
Expand Down
9 changes: 6 additions & 3 deletions tests/vocabulary.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ const read = (...paths) => {
const path = paths.find((p) => existsSync(p));
return path ? readFileSync(path, 'utf8') : null;
};
const tagbrush = read('node_modules/tagbrush/llms.txt');
const tagaction = read('node_modules/tagaction/llms.txt', '../tagaction/llms.txt');
// A checkout next to this repo is newer than the installed release, so it
// comes first; CI, without one, checks against the installed packages.
const tagbrush = read('../tagbrush/llms.txt', 'node_modules/tagbrush/llms.txt');
const tagaction = read('../tagaction/llms.txt', 'node_modules/tagaction/llms.txt');

test('every class TagBrush.css documents is known, and nothing else', () => {
const documented = new Set([
...[...tagbrush.matchAll(/class="([^"]+)"/g)].flatMap((m) => m[1].split(/\s+/)),
...[...tagbrush.matchAll(/`\.([a-z][a-z-]*)`/g)].map((m) => m[1]),
// `.pdf`, `.docx`, … are file endings (document links), not classes
...[...tagbrush.matchAll(/`\.([a-z][a-z-]*)`/g)].map((m) => m[1]).filter((name) => !['pdf', 'doc', 'docx', 'xls', 'xlsx', 'csv', 'zip'].includes(name)),
'tagbrush', // the scoped build's wrapper class (README)
]);
expect([...documented].sort()).toEqual([...CLASSES].sort());
Expand Down
Loading