@clockgrove/assetgrove-icons 0.0.0-stage → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Clockgrove
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,98 @@
1
- # Temporary Holding Version
1
+ # @clockgrove/assetgrove-icons
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The icons pack for Assetgrove: one icon per asset, at one size, checked against the backgrounds it will sit on.
4
+
5
+ ## Extension API
6
+
7
+ The package declares `"assetgrove": { "api": 3 }` and a peer range on `@clockgrove/assetgrove`. It declares, as extension `icons`, the kind `icons:family` with its operations `icons:still` and `icons:identify` and its two checks.
8
+
9
+ ## Install
10
+
11
+ Install it beside core and list it in the developer settings:
12
+
13
+ ```json
14
+ { "extensions": ["@clockgrove/assetgrove-icons"] }
15
+ ```
16
+
17
+ ## The `icons:family` kind
18
+
19
+ An icon family is the assets that share a `subject`. Each asset is one icon at one size.
20
+
21
+ ```json
22
+ { "kind": "icons:family", "assetId": "save-idle", "subject": "save" }
23
+ ```
24
+
25
+ The target profile carries a `kinds["icons:family"]` block:
26
+
27
+ ```json
28
+ {
29
+ "kinds": {
30
+ "icons:family": {
31
+ "size": 32,
32
+ "backgrounds": ["#f4efe1", "#1d2b35"],
33
+ "layout": { "media": "assets/icons/{{spec.subject}}/{{spec.assetId}}.{{output.extension}}" }
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ - `size`: whole pixels, the side of a square icon.
40
+ - `backgrounds`: a non-empty list of flat `#rrggbb` colours the icon will sit on.
41
+ - `layout`: optional, as for any kind (`kinds.<kind>.layout`). An icon has no animation family, so a layout names the subject and asset id.
42
+
43
+ A profile without the block is refused at plan: exit 2 `invalid_input`.
44
+
45
+ The kind generates with the operation `icons:still` (role `image`). It scales the image to fit `size` × `size`, centred, and applies the profile's alpha and colour rule. It passes no typed call parameters, so it works on any image route.
46
+
47
+ ## Checks
48
+
49
+ ### `icons:boundary-contrast`
50
+
51
+ Exact, free, and it filters. For each declared background the icon is composited over it. The boundary is taken at the profile's `style.alpha.threshold` (core's default: 1 for soft alpha, 128 for binary):
52
+
53
+ - an icon pixel is inside when its alpha is at least the threshold;
54
+ - a boundary pixel is an inside pixel with a left, right, up or down neighbour outside;
55
+ - that neighbour is its adjacent background pixel. It is composited too, so a soft edge below the threshold counts as background. Beyond the image edge it is the bare background.
56
+
57
+ The WCAG 2.2 contrast ratio of each pair (WCAG's relative luminance and `(L1 + 0.05) / (L2 + 0.05)`) is computed unrounded. The check fails when the minimum is below 3:1. There is one reason per background, naming the background and the ratio, shown truncated to three decimals and never rounded up: 2.9996 reads `2.999:1`. An icon with nothing visible at the threshold fails.
58
+
59
+ Set the threshold. Under soft alpha core's default threshold is 1, so every faintly visible pixel is inside. Scaling a source whose side is not a whole multiple of `size` blends its edge into pixels of low alpha, and those become the boundary: composited, they sit close to the background, and the check fails on every background even for a dark icon on white (a `#2b2b2b` square scaled from 60px to 16px fails on `#ffffff`; from 64px, or with binary alpha, it passes at 14.159:1). Set `style.alpha.threshold` in the profile to the alpha at which an edge pixel counts as the icon (128 judges the half-covered edge), or set `style.alpha.mode` to `"binary"`:
60
+
61
+ ```json
62
+ { "style": { "alpha": { "mode": "soft", "threshold": 128 } } }
63
+ ```
64
+
65
+ It uses WCAG's formula. It does not prove WCAG conformance: non-text contrast in WCAG depends on what the icon conveys and on its real surroundings, which the check cannot know.
66
+
67
+ ### `icons:identifiable`
68
+
69
+ A model check, advisory. For each background it makes one boolean decision (operation `icons:identify`, role `decisions`): is the icon recognisable as its subject over that background. The pack ships no stability entry, so its reasons are advisory (`shadow`) and never filter, until a measured stability entry qualifies it ([QA checks](../../docs/extensions.md#qa-checks)).
70
+
71
+ ## Family consistency
72
+
73
+ There is no new check. Audit the family as a folder:
74
+
75
+ ```sh
76
+ assetgrove audit asset://<game>/by-subject/<family>/
77
+ assetgrove audit asset://<game>/by-subject/<family>/ --dry-run
78
+ ```
79
+
80
+ The audit scores each member's style against the bible and the other members, and reports the spread and the set-consistency bar. `--dry-run` prints the forecast.
81
+
82
+ ## Routing
83
+
84
+ Settings `routes["icons:still"]` and `routes["icons:identify"]` choose the route. Without them the roles `image` and `decisions` do.
85
+
86
+ ## Limits
87
+
88
+ One size only. Size sets and icon atlases come after 1.0.
89
+
90
+ ## Development
91
+
92
+ ```sh
93
+ pnpm install --frozen-lockfile --ignore-scripts
94
+ pnpm check
95
+ pnpm test
96
+ ```
97
+
98
+ The tests use the scripted provider and never call a model.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The boundary contrast measure of an icon: WCAG 2.2's contrast ratio between each boundary pixel
3
+ * and the background pixel beside it, both composited over a flat background. Pure arithmetic over
4
+ * RGBA bytes, so it needs nothing from core.
5
+ */
6
+ /** Red, green and blue, each 0..255. */
7
+ export type Rgb = readonly [number, number, number];
8
+ /** An 8-bit RGBA image, row-major (core's `Raster`). */
9
+ export interface Pixels {
10
+ width: number;
11
+ height: number;
12
+ data: Uint8Array;
13
+ }
14
+ /** The lowest contrast ratio an icon's boundary may have. */
15
+ export declare const MIN_CONTRAST = 3;
16
+ /** WCAG 2.2's relative luminance of an sRGB colour (channels may be fractional). */
17
+ export declare function relativeLuminance([r, g, b]: Rgb): number;
18
+ /** WCAG 2.2's contrast ratio of two colours, unrounded: 1 for the same colour, 21 for black on white. */
19
+ export declare function contrastRatio(a: Rgb, b: Rgb): number;
20
+ /** A straight-alpha colour over a background, unrounded. */
21
+ export declare function compositeOver(fg: Rgb, alpha: number, bg: Rgb): [number, number, number];
22
+ /** A ratio cut (not rounded) to three decimals, so 2.9999 reads 2.999 and never 3.000. */
23
+ export declare function formatRatio(ratio: number): string;
24
+ export interface BoundaryContrast {
25
+ /** The lowest ratio over every boundary pixel and neighbour; undefined when nothing is at the threshold. */
26
+ minimum: number | undefined;
27
+ /** How many (boundary pixel, outside neighbour) pairs were measured. */
28
+ pairs: number;
29
+ }
30
+ /**
31
+ * The minimum contrast over the icon's boundary on `background`. A pixel is inside when its alpha
32
+ * is at least `threshold`; a boundary pixel is an inside pixel with a 4-neighbour outside, and each
33
+ * such pair is measured, both composited over the background. A neighbour beyond the image is the
34
+ * bare background.
35
+ */
36
+ export declare function boundaryContrast(image: Pixels, threshold: number, background: Rgb): BoundaryContrast;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The boundary contrast measure of an icon: WCAG 2.2's contrast ratio between each boundary pixel
3
+ * and the background pixel beside it, both composited over a flat background. Pure arithmetic over
4
+ * RGBA bytes, so it needs nothing from core.
5
+ */
6
+ /** The lowest contrast ratio an icon's boundary may have. */
7
+ export const MIN_CONTRAST = 3;
8
+ /** WCAG 2.2's relative luminance of an sRGB colour (channels may be fractional). */
9
+ export function relativeLuminance([r, g, b]) {
10
+ const linear = (channel) => {
11
+ const c = channel / 255;
12
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
13
+ };
14
+ return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);
15
+ }
16
+ /** WCAG 2.2's contrast ratio of two colours, unrounded: 1 for the same colour, 21 for black on white. */
17
+ export function contrastRatio(a, b) {
18
+ const la = relativeLuminance(a);
19
+ const lb = relativeLuminance(b);
20
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
21
+ }
22
+ /** A straight-alpha colour over a background, unrounded. */
23
+ export function compositeOver(fg, alpha, bg) {
24
+ const a = alpha / 255;
25
+ return [0, 1, 2].map((i) => a * fg[i] + (1 - a) * bg[i]);
26
+ }
27
+ /** A ratio cut (not rounded) to three decimals, so 2.9999 reads 2.999 and never 3.000. */
28
+ export function formatRatio(ratio) {
29
+ return (Math.floor(ratio * 1000) / 1000).toFixed(3);
30
+ }
31
+ const NEIGHBOURS = [
32
+ [1, 0],
33
+ [-1, 0],
34
+ [0, 1],
35
+ [0, -1],
36
+ ];
37
+ /**
38
+ * The minimum contrast over the icon's boundary on `background`. A pixel is inside when its alpha
39
+ * is at least `threshold`; a boundary pixel is an inside pixel with a 4-neighbour outside, and each
40
+ * such pair is measured, both composited over the background. A neighbour beyond the image is the
41
+ * bare background.
42
+ */
43
+ export function boundaryContrast(image, threshold, background) {
44
+ const { width, height, data } = image;
45
+ const alphaAt = (x, y) => data[(y * width + x) * 4 + 3] ?? 0;
46
+ const over = (x, y) => {
47
+ const i = (y * width + x) * 4;
48
+ return compositeOver([data[i] ?? 0, data[i + 1] ?? 0, data[i + 2] ?? 0], data[i + 3] ?? 0, background);
49
+ };
50
+ let minimum;
51
+ let pairs = 0;
52
+ for (let y = 0; y < height; y++)
53
+ for (let x = 0; x < width; x++) {
54
+ if (alphaAt(x, y) < threshold)
55
+ continue;
56
+ const inside = over(x, y);
57
+ for (const [dx, dy] of NEIGHBOURS) {
58
+ const nx = x + dx;
59
+ const ny = y + dy;
60
+ const beyond = nx < 0 || ny < 0 || nx >= width || ny >= height;
61
+ if (!beyond && alphaAt(nx, ny) >= threshold)
62
+ continue;
63
+ const ratio = contrastRatio(inside, beyond ? background : over(nx, ny));
64
+ pairs++;
65
+ if (minimum === undefined || ratio < minimum)
66
+ minimum = ratio;
67
+ }
68
+ }
69
+ return { minimum, pairs };
70
+ }
@@ -0,0 +1,3 @@
1
+ /** The icons pack's entry for core's extension API (api 3): the `icons:family` kind. */
2
+ import type { Extension, ExtensionContext } from "@clockgrove/assetgrove/extension";
3
+ export default function iconsExtension(context: ExtensionContext): Extension;
@@ -0,0 +1,4 @@
1
+ import { iconsFamilyKind } from "./kind.js";
2
+ export default function iconsExtension(context) {
3
+ return { api: context.api, name: "icons", kinds: [iconsFamilyKind(context)] };
4
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./contrast.ts";
2
+ export * from "./kind.ts";
3
+ export { default as iconsExtension } from "./extension.ts";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./contrast.js";
2
+ export * from "./kind.js";
3
+ export { default as iconsExtension } from "./extension.js";
package/dist/kind.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { AssetKind, ExtensionContext } from "@clockgrove/assetgrove/extension";
2
+ export declare const ICONS_KIND = "icons:family";
3
+ export declare const STILL_OPERATION = "icons:still";
4
+ export declare const IDENTIFY_OPERATION = "icons:identify";
5
+ export declare const BOUNDARY_CONTRAST_CHECK = "icons:boundary-contrast";
6
+ export declare const IDENTIFIABLE_CHECK = "icons:identifiable";
7
+ /** The profile's `kinds["icons:family"]` block, without `values` and `layout`. */
8
+ export interface IconsProfile {
9
+ size: number;
10
+ backgrounds: string[];
11
+ }
12
+ export declare function iconsFamilyKind(context: ExtensionContext): AssetKind;
package/dist/kind.js ADDED
@@ -0,0 +1,154 @@
1
+ /**
2
+ * The `icons:family` kind: one icon per asset at one size, checked for boundary contrast against
3
+ * each background the target profile declares. An icon family is the assets that share a `subject`.
4
+ */
5
+ import { createHash } from "node:crypto";
6
+ import { MIN_CONTRAST, boundaryContrast, compositeOver, formatRatio } from "./contrast.js";
7
+ export const ICONS_KIND = "icons:family";
8
+ export const STILL_OPERATION = "icons:still";
9
+ export const IDENTIFY_OPERATION = "icons:identify";
10
+ export const BOUNDARY_CONTRAST_CHECK = "icons:boundary-contrast";
11
+ export const IDENTIFIABLE_CHECK = "icons:identifiable";
12
+ /** An error core maps to exit 2 `invalid_input` by its own code. */
13
+ function invalidInput(message) {
14
+ return Object.assign(new Error(message), { code: "invalid_input" });
15
+ }
16
+ function hexRgb(hex) {
17
+ const n = parseInt(hex.slice(1), 16);
18
+ return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
19
+ }
20
+ export function iconsFamilyKind(context) {
21
+ const { z, raster } = context;
22
+ const profileSchema = z.strictObject({
23
+ size: z.number().int().positive(),
24
+ backgrounds: z.array(z.string().regex(/^#[0-9a-fA-F]{6}$/)).min(1),
25
+ });
26
+ /** The kind's block of the profile, validated; its `values` and `layout` are core's. */
27
+ function iconsProfileOf(profile) {
28
+ const block = profile.kinds?.[ICONS_KIND];
29
+ if (block === undefined)
30
+ throw invalidInput(`the target profile has no kinds["${ICONS_KIND}"] block (size, backgrounds)`);
31
+ const own = Object.fromEntries(Object.entries(block).filter(([field]) => field !== "values" && field !== "layout"));
32
+ const parsed = profileSchema.safeParse(own);
33
+ if (!parsed.success)
34
+ throw invalidInput(`kinds["${ICONS_KIND}"] is invalid: ${parsed.error.issues
35
+ .map((i) => `${i.path.join(".") || "(block)"} ${i.message}`)
36
+ .join("; ")}`);
37
+ return parsed.data;
38
+ }
39
+ const thresholdOf = (profile, bible) => raster.resolveStyle(profile.style, bible.palette).alpha.threshold;
40
+ const boundaryContrastCheck = {
41
+ name: BOUNDARY_CONTRAST_CHECK,
42
+ mode: "exact",
43
+ source: "deterministic",
44
+ run({ profile, bible, output }) {
45
+ const { backgrounds } = iconsProfileOf(profile);
46
+ const threshold = thresholdOf(profile, bible);
47
+ const icon = raster.decode(output.bytes);
48
+ return backgrounds.map((background) => {
49
+ const { minimum } = boundaryContrast(icon, threshold, hexRgb(background));
50
+ const base = { check: BOUNDARY_CONTRAST_CHECK, source: "deterministic" };
51
+ if (minimum === undefined)
52
+ return {
53
+ ...base,
54
+ passed: false,
55
+ reason: `boundary contrast on ${background}: nothing visible at the threshold ${threshold}`,
56
+ };
57
+ const passed = minimum >= MIN_CONTRAST;
58
+ return {
59
+ ...base,
60
+ passed,
61
+ reason: `boundary contrast on ${background} is ${formatRatio(minimum)}:1, ${passed ? "at least" : "below"} ${MIN_CONTRAST}:1`,
62
+ };
63
+ });
64
+ },
65
+ };
66
+ const identifiableCheck = {
67
+ name: IDENTIFIABLE_CHECK,
68
+ mode: "model",
69
+ operation: IDENTIFY_OPERATION,
70
+ version: "1",
71
+ source: "decision",
72
+ async run({ spec, profile, output }, call) {
73
+ const { backgrounds } = iconsProfileOf(profile);
74
+ const subject = context.prompt.subjectOf(spec);
75
+ const icon = raster.decode(output.bytes);
76
+ const reasons = [];
77
+ for (const background of backgrounds) {
78
+ const bg = hexRgb(background);
79
+ const flat = raster.create(icon.width, icon.height);
80
+ for (let y = 0; y < icon.height; y++)
81
+ for (let x = 0; x < icon.width; x++) {
82
+ const [r, g, b, a] = raster.getPixel(icon, x, y);
83
+ const [cr, cg, cb] = compositeOver([r, g, b], a, bg);
84
+ raster.setPixel(flat, x, y, [Math.round(cr), Math.round(cg), Math.round(cb), 255]);
85
+ }
86
+ const bytes = raster.encodePng(flat);
87
+ const reference = {
88
+ role: "icon",
89
+ path: `icon-on-${background}.png`,
90
+ mediaType: "image/png",
91
+ bytes,
92
+ sha256: createHash("sha256").update(bytes).digest("hex"),
93
+ };
94
+ const { result } = await call.decide(IDENTIFY_OPERATION, `The image shows a UI icon of "${subject}" on a flat ${background} background.`, [reference], {
95
+ type: "boolean",
96
+ instructions: `Is the icon in this image recognisable as ${subject}, at a glance, against its ${background} background?`,
97
+ whenTrue: "the icon is recognisable",
98
+ whenFalse: "the icon is not recognisable",
99
+ });
100
+ const answer = result.answer;
101
+ const passed = answer.type === "boolean" && answer.probability >= 0.5;
102
+ reasons.push({
103
+ check: IDENTIFIABLE_CHECK,
104
+ passed,
105
+ reason: `the icon is ${passed ? "" : "not "}recognisable as ${subject} on ${background}`,
106
+ source: "decision",
107
+ });
108
+ }
109
+ return reasons;
110
+ },
111
+ };
112
+ return {
113
+ kind: ICONS_KIND,
114
+ operations: { [STILL_OPERATION]: "image", [IDENTIFY_OPERATION]: "decisions" },
115
+ profileSchema,
116
+ checks: [boundaryContrastCheck, identifiableCheck],
117
+ planCandidate(_spec, profile, routes) {
118
+ const { backgrounds } = iconsProfileOf(profile);
119
+ const plan = (operation) => {
120
+ const route = routes[operation];
121
+ if (route === undefined)
122
+ throw invalidInput(`no route for the ${operation} operation`);
123
+ return { operation, model: route.model, estimatedCostUsd: route.estimatedCostUsd };
124
+ };
125
+ return [plan(STILL_OPERATION), ...backgrounds.map(() => plan(IDENTIFY_OPERATION))];
126
+ },
127
+ async generate(ctx) {
128
+ const { size, backgrounds } = iconsProfileOf(ctx.profile);
129
+ const style = raster.resolveStyle(ctx.profile.style, ctx.bible.palette);
130
+ const subject = context.prompt.subjectOf(ctx.spec);
131
+ const prompt = context.prompt.withNote([
132
+ `A single UI icon of ${subject}, centred, on a transparent background, readable at ${size}px.`,
133
+ `Palette, use only these colours: ${ctx.bible.palette.join(", ")}.`,
134
+ ...context.prompt.styleNotes(ctx.spec, ctx.bible).map((n) => `Style note: ${n}`),
135
+ ].join("\n"), ctx.note);
136
+ const image = await ctx.call.image(STILL_OPERATION, prompt, [], ctx.seed);
137
+ const source = raster.decode(image.bytes);
138
+ const scale = Math.min(size / source.width, size / source.height);
139
+ const fitted = raster.scale(source, scale, { x: (size - source.width * scale) / 2, y: (size - source.height * scale) / 2 }, { width: size, height: size }, style.edges);
140
+ const icon = raster.applyStyle(fitted, style);
141
+ return {
142
+ output: {
143
+ mediaType: "image/png",
144
+ extension: "png",
145
+ bytes: raster.encodePng(icon),
146
+ fields: { size },
147
+ },
148
+ qa: { passed: true, reasons: [] },
149
+ prompt,
150
+ parameters: { size, backgrounds },
151
+ };
152
+ },
153
+ };
154
+ }
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@clockgrove/assetgrove-icons",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.3.2",
4
+ "description": "UI icon families for Assetgrove: one icon per asset at one size, with a boundary contrast check against each background.",
5
+ "keywords": [
6
+ "assetgrove",
7
+ "icons",
8
+ "ui",
9
+ "contrast",
10
+ "gamedev"
11
+ ],
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/clockgrove/assetgrove.git",
16
+ "directory": "packages/assetgrove-icons"
17
+ },
18
+ "type": "module",
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "assetgrove": {
29
+ "api": 3,
30
+ "entry": "./dist/extension.js"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "skills"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "engines": {
40
+ "node": ">=24"
41
+ },
42
+ "peerDependencies": {
43
+ "@clockgrove/assetgrove": "^0.3.2"
44
+ },
45
+ "devDependencies": {
46
+ "@biomejs/biome": "2.6.9",
47
+ "@clockgrove/assetgrove": "link:../..",
48
+ "@types/node": "24.19.2",
49
+ "typescript": "6.0.3"
50
+ },
51
+ "scripts": {
52
+ "build": "tsc -p ../../tsconfig.build.json --emitDeclarationOnly && tsc -p tsconfig.build.json",
53
+ "check": "biome check . && tsc --noEmit",
54
+ "format": "biome format --write .",
55
+ "test": "node --conditions=assetgrove-source --test \"test/**/*.test.ts\""
56
+ }
6
57
  }
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: assetgrove-icons
3
+ description: Load when an Assetgrove project makes icons, one icon per asset at one size, that must stay readable on set backgrounds. Needs the optional @clockgrove/assetgrove-icons package listed in the developer settings; covers the icons:family kind, its profile block, the icons:boundary-contrast and icons:identifiable checks, auditing a family and its limits.
4
+ ---
5
+
6
+ # Assetgrove for icons
7
+
8
+ `@clockgrove/assetgrove-icons` is a pack: it loads only once a person lists it under `extensions` in the developer settings. It adds the kind `icons:family`: one icon per asset, at one size.
9
+
10
+ ## Set it up
11
+
12
+ - Install it beside core and list `@clockgrove/assetgrove-icons` in `extensions`.
13
+ - Add `kinds["icons:family"]` to the target profile. `size` is the side of a square icon in whole pixels. `backgrounds` is a non-empty list of flat `#rrggbb` colours the icon will sit on. `layout` is optional (`kinds.<kind>.layout`).
14
+
15
+ ```json
16
+ {
17
+ "kinds": {
18
+ "icons:family": {
19
+ "size": 32,
20
+ "backgrounds": ["#f4efe1", "#1d2b35"],
21
+ "layout": { "media": "assets/icons/{{spec.subject}}/{{spec.assetId}}.{{output.extension}}" }
22
+ }
23
+ }
24
+ }
25
+ ```
26
+
27
+ A profile without the block exits 2 `invalid_input` at plan.
28
+
29
+ ## Make an icon
30
+
31
+ An icon family is the assets that share a `subject`. Name it in each spec:
32
+
33
+ ```json
34
+ { "kind": "icons:family", "assetId": "save-idle", "subject": "save" }
35
+ ```
36
+
37
+ Then `assetgrove stage --spec <spec.json> --bible <BIBLE.md> --profile <profile.json>`; add `--dry-run` for the forecast. The pack generates with `icons:still` (role `image`), scales the image to fit `size` × `size`, centred, and applies the profile's alpha and colour rule. It sets no typed call parameters, so any image route works. Routes: settings `routes["icons:still"]` and `routes["icons:identify"]`, else roles `image` and `decisions`.
38
+
39
+ ## Read the checks
40
+
41
+ - `icons:boundary-contrast` is exact, free and filters. It composites the icon over each background and takes the boundary at `style.alpha.threshold`. It fails when the lowest WCAG contrast ratio, between boundary pixels and their adjacent background, is below 3:1. There is one reason per background, naming it and the ratio truncated to three decimals (2.9996 reads `2.999:1`). An icon with nothing visible at the threshold fails. Do not retry the same image.
42
+ - Set `style.alpha.threshold` (128 judges the half-covered edge) or `style.alpha.mode: "binary"` in the profile before you make icons. Under soft alpha the default threshold is 1: the faint edge pixels that scaling to `size` leaves become the boundary, and they fail on every background even for a well-contrasted icon. When the check fails on every background, look at the threshold first; otherwise fix the icon or the backgrounds.
43
+ - `icons:identifiable` asks a model, once per background, whether the icon is recognisable as its subject. It is advisory (`shadow`) and never filters, as the pack ships no stability entry. Treat its reasons as a prompt for a person.
44
+
45
+ The first check uses WCAG's formula. It does not prove WCAG conformance, which depends on what the icon conveys and its real surroundings.
46
+
47
+ ## Audit a family
48
+
49
+ There is no family check. Audit the subject's folder:
50
+
51
+ ```sh
52
+ assetgrove audit asset://<game>/by-subject/<family>/ --dry-run
53
+ assetgrove audit asset://<game>/by-subject/<family>/
54
+ ```
55
+
56
+ It scores each member's style against the bible and the other members, and reports the spread and the set-consistency bar. The audit informs a person; it never rejects or approves.
57
+
58
+ ## Limits
59
+
60
+ One size per profile. Size sets and icon atlases come after 1.0.