@shavin/skills 0.0.0-stage → 0.1.0
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/AGENTS.md +193 -0
- package/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +48 -2
- package/bin/hex-policy.mjs +157 -0
- package/bin/install.mjs +219 -0
- package/bin/lint-tokens.mjs +178 -0
- package/build.mjs +540 -0
- package/commands/add-composition.md +14 -0
- package/commands/apply-theme.md +59 -0
- package/commands/audit-layout.md +15 -0
- package/commands/audit-ui.md +42 -0
- package/commands/compose-page.md +16 -0
- package/commands/create-block.md +79 -0
- package/commands/create-primitive.md +40 -0
- package/commands/create-screen.md +45 -0
- package/commands/create-theme.md +41 -0
- package/cursor/shavin.mdc +14 -0
- package/package.json +66 -4
- package/posix-path.mjs +7 -0
- package/skills/core-rules.md +294 -0
- package/skills/layout-choreography/SKILL.md +102 -0
- package/skills/layout-choreography/references/fallbacks-and-accessibility.md +76 -0
- package/skills/layout-choreography/references/scenes.md +113 -0
- package/skills/layout-choreography/references/shavin-timelines.md +100 -0
- package/skills/layout-choreography/references/tech-and-performance.md +147 -0
- package/skills/layout-compositions/SKILL.md +149 -0
- package/skills/layout-compositions/references/adapters/shavin-ui.md +122 -0
- package/skills/layout-compositions/references/adapters/tailwind-html.md +100 -0
- package/skills/layout-compositions/references/component-language.md +105 -0
- package/skills/layout-compositions/references/compositions/conversion.md +286 -0
- package/skills/layout-compositions/references/compositions/documentation.md +125 -0
- package/skills/layout-compositions/references/compositions/editorial.md +126 -0
- package/skills/layout-compositions/references/compositions/expressive.md +151 -0
- package/skills/layout-compositions/references/compositions/features.md +262 -0
- package/skills/layout-compositions/references/compositions/gallery.md +172 -0
- package/skills/layout-compositions/references/compositions/hero.md +184 -0
- package/skills/layout-compositions/references/compositions/proof.md +194 -0
- package/skills/layout-compositions/references/compositions/structural.md +173 -0
- package/skills/layout-compositions/references/distinctiveness.md +65 -0
- package/skills/layout-compositions/references/foundations.md +119 -0
- package/skills/layout-compositions/references/metadata-schema.md +64 -0
- package/skills/layout-compositions/references/page-recipes.md +143 -0
- package/skills/layout-compositions/references/selection-guide.md +207 -0
- package/skills/layout-compositions/references/treatments.md +60 -0
- package/skills/layout-compositions/references/unsection-source-examples.md +92 -0
- package/skills/layout-compositions/references/visual-review.md +40 -0
- package/skills/layout-compositions/scripts/render_wireframes.py +138 -0
- package/skills/layout-compositions/scripts/validate_library.py +165 -0
- package/skills/layout-motion/SKILL.md +83 -0
- package/skills/layout-motion/references/composition-motion-map.md +69 -0
- package/skills/layout-motion/references/presets.md +209 -0
- package/skills/layout-motion/references/tokens.md +100 -0
- package/skills/shavin-app/SKILL.md +242 -0
- package/skills/shavin-app/patterns.md +35 -0
- package/skills/shavin-studio/SKILL.md +97 -0
- package/skills/shavin-webpage/SKILL.md +210 -0
- package/skills/shavin-webpage/editorial-craft.md +117 -0
- package/skills/shavin-webpage/page-architecture.md +137 -0
- package/skills/shavin-webpage/style-recipes.md +107 -0
- package/skills/visual-compositor/SKILL.md +200 -0
- package/skills/visual-compositor/anti-patterns.md +109 -0
- package/skills/visual-compositor/audit-checklist.md +162 -0
- package/skills/visual-compositor/cognitive-layer.md +287 -0
- package/skills/visual-compositor/composition-motion-map.md +167 -0
- package/skills/visual-compositor/concentric-laws.md +147 -0
- package/skills/visual-compositor/docs-mode.md +32 -0
- package/skills/visual-compositor/editorial-mode.md +48 -0
- package/skills/visual-compositor/font-pairings.md +224 -0
- package/skills/visual-compositor/graphics-and-assets.md +128 -0
- package/skills/visual-compositor/interface-polish.md +125 -0
- package/skills/visual-compositor/layout-restraint.md +80 -0
- package/skills/visual-compositor/motion-and-physics.md +257 -0
- package/skills/visual-compositor/page-motion-presets.md +246 -0
- package/skills/visual-compositor/references/EDITORIAL_EXPRESSIVE.md +163 -0
- package/skills/visual-compositor/spacing-core.md +386 -0
- package/skills/visual-compositor/spacing-dense.md +63 -0
- package/skills/visual-compositor/spacing-marketing.md +192 -0
- package/skills/visual-compositor/typography-rules.md +114 -0
- package/token-budget.json +86 -0
package/build.mjs
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* build.mjs — Shavin Skills Build & Deploy Script
|
|
4
|
+
*
|
|
5
|
+
* Lives at packages/skills/build.mjs. Validates the skill .md files in
|
|
6
|
+
* packages/skills/skills/ and deploys them to .agents/skills/ (repository
|
|
7
|
+
* consumption). The skills/ directory is both the source of truth AND the
|
|
8
|
+
* published npm content — no separate source/output split.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* node build.mjs # Validate + measure + sync to .agents/skills/
|
|
12
|
+
* node build.mjs --dry-run # Validate + measure + diff report, NO sync
|
|
13
|
+
* node build.mjs --tokens # Measure tokens only (quick check)
|
|
14
|
+
* node build.mjs --strict # Treat budget warnings as errors
|
|
15
|
+
* node build.mjs --target X # Override target dir (default: <repo>/.agents/skills)
|
|
16
|
+
*
|
|
17
|
+
* What it does:
|
|
18
|
+
* 1. Validate cross-references — every `filename.md` mentioned in any .md file must exist
|
|
19
|
+
* 2. Validate frontmatter — every `file:` in SKILL.md frontmatter must resolve to a real file
|
|
20
|
+
* 3. Measure tokens — per file, per skill, always-loaded total, on-demand totals
|
|
21
|
+
* 4. Diff report — compare skills/ vs .agents/skills/, show changed/added/removed
|
|
22
|
+
* 5. Sync — copy changed files from skills/ to .agents/skills/
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, copyFileSync, unlinkSync } from "node:fs";
|
|
26
|
+
import { resolve, join, relative, dirname, basename } from "node:path";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
import { createHash } from "node:crypto";
|
|
29
|
+
import { c, g, fmt, printBanner, printCard } from "../../scripts/lib/term-ui.mjs";
|
|
30
|
+
import { relPosix } from "./posix-path.mjs";
|
|
31
|
+
|
|
32
|
+
// Parse CLI flags
|
|
33
|
+
const args = process.argv.slice(2);
|
|
34
|
+
const isDryRun = args.includes("--dry-run");
|
|
35
|
+
const isTokensOnly = args.includes("--tokens");
|
|
36
|
+
const isStrict = args.includes("--strict");
|
|
37
|
+
const targetIdx = args.indexOf("--target");
|
|
38
|
+
const targetOverride = targetIdx !== -1 && args[targetIdx + 1] ? args[targetIdx + 1] : null;
|
|
39
|
+
|
|
40
|
+
// ── Setup paths ──
|
|
41
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
42
|
+
const __dirname = dirname(__filename); // packages/skills/
|
|
43
|
+
const SKILLS_SRC = join(__dirname, "skills"); // packages/skills/skills/ — source of truth + npm content
|
|
44
|
+
const REPO_ROOT = resolve(__dirname, "..", ".."); // repository root (2 levels up)
|
|
45
|
+
const AGENTS_DIR = targetOverride || join(REPO_ROOT, ".agents", "skills");
|
|
46
|
+
|
|
47
|
+
// ── Helpers ──
|
|
48
|
+
|
|
49
|
+
// References that are not skill files — they're root-level project files or external.
|
|
50
|
+
// The validator skips these instead of reporting them as missing.
|
|
51
|
+
const EXTERNAL_REFS = new Set([
|
|
52
|
+
"AGENTS.md",
|
|
53
|
+
"CLAUDE.md",
|
|
54
|
+
"SHAVIN.md",
|
|
55
|
+
"README.md",
|
|
56
|
+
"core-rules.md", // core-rules.md is a shared file, not always inside every skill dir
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
function tok(n) { return Math.round(n / 4); }
|
|
60
|
+
|
|
61
|
+
function hashFile(path) {
|
|
62
|
+
try {
|
|
63
|
+
return createHash("md5").update(readFileSync(path)).digest("hex");
|
|
64
|
+
} catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function walkDir(dir, ext = ".md") {
|
|
70
|
+
const results = [];
|
|
71
|
+
function walk(d) {
|
|
72
|
+
for (const entry of readdirSync(d)) {
|
|
73
|
+
const full = join(d, entry);
|
|
74
|
+
if (statSync(full).isDirectory()) {
|
|
75
|
+
walk(full);
|
|
76
|
+
} else if (entry.endsWith(ext) || entry.endsWith(".json")) {
|
|
77
|
+
results.push(full);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
walk(dir);
|
|
82
|
+
return results;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function color(text, code) {
|
|
86
|
+
return `\x1b[${code}m${text}\x1b[0m`;
|
|
87
|
+
}
|
|
88
|
+
const green = (t) => color(t, 32);
|
|
89
|
+
const red = (t) => color(t, 31);
|
|
90
|
+
const yellow = (t) => color(t, 33);
|
|
91
|
+
const cyan = (t) => color(t, 36);
|
|
92
|
+
const dim = (t) => color(t, 2);
|
|
93
|
+
const bold = (t) => color(t, 1);
|
|
94
|
+
|
|
95
|
+
let warnings = 0;
|
|
96
|
+
let errors = 0;
|
|
97
|
+
|
|
98
|
+
function warn(msg) {
|
|
99
|
+
console.log(` ${yellow("⚠ WARN")} ${msg}`);
|
|
100
|
+
warnings++;
|
|
101
|
+
if (isStrict) errors++;
|
|
102
|
+
}
|
|
103
|
+
function err(msg) {
|
|
104
|
+
console.log(` ${red("✗ ERROR")} ${msg}`);
|
|
105
|
+
errors++;
|
|
106
|
+
}
|
|
107
|
+
function ok(msg) {
|
|
108
|
+
console.log(` ${green("✓ OK")} ${msg}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ── Step 1: Collect all files ──
|
|
112
|
+
// Exclude non-skill files that might exist in the tree (defensive — these
|
|
113
|
+
// shouldn't be in skills/ but the filter prevents accidental deployment).
|
|
114
|
+
const NON_SKILL_FILES = new Set(["build.mjs", "token-budget.json", "README.md", "package.json"]);
|
|
115
|
+
const allFiles = walkDir(SKILLS_SRC).filter(f => {
|
|
116
|
+
const base = basename(f);
|
|
117
|
+
// Exclude by filename anywhere in the tree
|
|
118
|
+
if (NON_SKILL_FILES.has(base)) return false;
|
|
119
|
+
// Exclude .mjs files
|
|
120
|
+
if (f.endsWith(".mjs")) return false;
|
|
121
|
+
// Exclude .json files at root level (budget config, package.json)
|
|
122
|
+
if (f.endsWith(".json") && dirname(f) === SKILLS_SRC) return false;
|
|
123
|
+
return true;
|
|
124
|
+
});
|
|
125
|
+
const skillDirs = readdirSync(SKILLS_SRC)
|
|
126
|
+
.filter(d => statSync(join(SKILLS_SRC, d)).isDirectory())
|
|
127
|
+
.map(d => ({ name: d, path: join(SKILLS_SRC, d) }));
|
|
128
|
+
|
|
129
|
+
// Collect command files for validation and sync
|
|
130
|
+
const COMMANDS_SRC = join(__dirname, "commands");
|
|
131
|
+
const commandFiles = existsSync(COMMANDS_SRC)
|
|
132
|
+
? readdirSync(COMMANDS_SRC).filter(f => f.endsWith(".md")).map(f => join(COMMANDS_SRC, f))
|
|
133
|
+
: [];
|
|
134
|
+
|
|
135
|
+
// Load budget config (lives at package root, not in skills/)
|
|
136
|
+
let budget = null;
|
|
137
|
+
const budgetPath = join(__dirname, "token-budget.json");
|
|
138
|
+
if (existsSync(budgetPath)) {
|
|
139
|
+
budget = JSON.parse(readFileSync(budgetPath, "utf8"));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
process.stdout.write("\n");
|
|
143
|
+
printBanner("@shavin/skills", `AI Agent Skills Library Build${isDryRun ? " (Dry Run)" : ""}`);
|
|
144
|
+
console.log(` ${c.fgSubtle}Source: ${SKILLS_SRC}${c.reset}`);
|
|
145
|
+
console.log(` ${c.fgSubtle}Target: ${AGENTS_DIR}${c.reset}`);
|
|
146
|
+
console.log(` ${c.fgSubtle}Files: ${allFiles.length} .md files in ${skillDirs.length} skill directories${c.reset}\n`);
|
|
147
|
+
|
|
148
|
+
if (isTokensOnly) {
|
|
149
|
+
const result = measureTokens();
|
|
150
|
+
printSummary(result.alwaysTotal);
|
|
151
|
+
process.exit(errors > 0 ? 1 : 0);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ── Step 2: Validate cross-references ──
|
|
155
|
+
console.log(bold("\n── Step 1: Cross-Reference Validation ──\n"));
|
|
156
|
+
|
|
157
|
+
// Build a set of all known filenames
|
|
158
|
+
const allFilenames = new Set(allFiles.map(f => basename(f)));
|
|
159
|
+
const allRelPaths = new Set(allFiles.map(f => relPosix(SKILLS_SRC, f)));
|
|
160
|
+
|
|
161
|
+
for (const file of allFiles) {
|
|
162
|
+
const content = readFileSync(file, "utf8");
|
|
163
|
+
const relFile = relPosix(SKILLS_SRC, file);
|
|
164
|
+
|
|
165
|
+
// Find all `filename.md` references in backticks
|
|
166
|
+
const refPattern = /`([a-zA-Z0-9_\-\/]+\.md)`/g;
|
|
167
|
+
let match;
|
|
168
|
+
const refs = new Set();
|
|
169
|
+
while ((match = refPattern.exec(content)) !== null) {
|
|
170
|
+
refs.add(match[1]);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
for (const ref of refs) {
|
|
174
|
+
// Skip known external references (root project files, not skill files)
|
|
175
|
+
if (EXTERNAL_REFS.has(ref)) continue;
|
|
176
|
+
|
|
177
|
+
// Check if it's a bare filename or a relative path
|
|
178
|
+
const refBase = basename(ref);
|
|
179
|
+
const refExists = allFilenames.has(refBase) || allRelPaths.has(ref) ||
|
|
180
|
+
existsSync(join(SKILLS_SRC, ref)) ||
|
|
181
|
+
existsSync(join(dirname(file), ref));
|
|
182
|
+
|
|
183
|
+
if (!refExists) {
|
|
184
|
+
err(`In ${relFile}: references \`${ref}\` but no such file found`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (warnings === 0 && errors === 0) {
|
|
189
|
+
ok("All cross-references resolve to existing files");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Validate cross-references in command files too
|
|
193
|
+
if (commandFiles.length > 0) {
|
|
194
|
+
for (const cmdFile of commandFiles) {
|
|
195
|
+
const content = readFileSync(cmdFile, "utf8");
|
|
196
|
+
const cmdName = basename(cmdFile);
|
|
197
|
+
const refPattern = /`([a-zA-Z0-9_\-\/]+\.md)`/g;
|
|
198
|
+
let match;
|
|
199
|
+
const refs = new Set();
|
|
200
|
+
while ((match = refPattern.exec(content)) !== null) {
|
|
201
|
+
refs.add(match[1]);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
for (const ref of refs) {
|
|
205
|
+
if (EXTERNAL_REFS.has(ref)) continue;
|
|
206
|
+
|
|
207
|
+
// Command files may reference skill files (e.g. `visual-compositor/SKILL.md`)
|
|
208
|
+
// or files relative to the skills source root.
|
|
209
|
+
const refBase = basename(ref);
|
|
210
|
+
const refExists = allFilenames.has(refBase) || allRelPaths.has(ref) ||
|
|
211
|
+
existsSync(join(SKILLS_SRC, ref)) ||
|
|
212
|
+
existsSync(join(dirname(cmdFile), ref));
|
|
213
|
+
|
|
214
|
+
if (!refExists) {
|
|
215
|
+
err(`In commands/${cmdName}: references \`${ref}\` but no such file found`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (warnings === 0 && errors === 0) {
|
|
220
|
+
ok("All command cross-references resolve to existing files");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ── Step 3: Validate frontmatter ──
|
|
225
|
+
console.log(bold("\n── Step 2: Frontmatter Validation ──\n"));
|
|
226
|
+
|
|
227
|
+
for (const skillDir of skillDirs) {
|
|
228
|
+
const skillMdPath = join(skillDir.path, "SKILL.md");
|
|
229
|
+
if (!existsSync(skillMdPath)) {
|
|
230
|
+
warn(`${skillDir.name}/ has no SKILL.md`);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const content = readFileSync(skillMdPath, "utf8");
|
|
235
|
+
// Extract frontmatter between --- markers
|
|
236
|
+
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
237
|
+
if (!fmMatch) {
|
|
238
|
+
warn(`${skillDir.name}/SKILL.md has no frontmatter`);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const fm = fmMatch[1];
|
|
243
|
+
// Find all `file: filename.md` entries in frontmatter
|
|
244
|
+
const filePattern = /file:\s*(\S+)/g;
|
|
245
|
+
let fmMatch2;
|
|
246
|
+
let filesInSection = [];
|
|
247
|
+
while ((fmMatch2 = filePattern.exec(fm)) !== null) {
|
|
248
|
+
filesInSection.push(fmMatch2[1]);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
for (const refFile of filesInSection) {
|
|
252
|
+
const fullPath = join(skillDir.path, refFile);
|
|
253
|
+
if (!existsSync(fullPath)) {
|
|
254
|
+
err(`${skillDir.name}/SKILL.md frontmatter references \`${refFile}\` but file not found at ${fullPath}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Check for orphan files (files in skill dir not in frontmatter and not SKILL.md)
|
|
259
|
+
const dirFiles = walkDir(skillDir.path)
|
|
260
|
+
.filter(f => basename(f) !== "SKILL.md" && f.endsWith(".md"))
|
|
261
|
+
.map(f => relPosix(skillDir.path, f));
|
|
262
|
+
|
|
263
|
+
for (const dirFile of dirFiles) {
|
|
264
|
+
if (!filesInSection.includes(dirFile)) {
|
|
265
|
+
// references/ subdirectory files are OK to not be in frontmatter
|
|
266
|
+
if (!dirFile.startsWith("references/")) {
|
|
267
|
+
warn(`${skillDir.name}/${dirFile} exists but is not listed in SKILL.md frontmatter`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (warnings === 0 && errors === 0) {
|
|
273
|
+
ok("All frontmatter file references resolve");
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ── Step 4: Measure tokens ──
|
|
277
|
+
function measureTokens() {
|
|
278
|
+
console.log(bold("\n── Step 3: Token Measurement ──\n"));
|
|
279
|
+
|
|
280
|
+
// Per-file measurements
|
|
281
|
+
const fileData = [];
|
|
282
|
+
for (const file of allFiles) {
|
|
283
|
+
const content = readFileSync(file, "utf8");
|
|
284
|
+
const relPath = relPosix(SKILLS_SRC, file);
|
|
285
|
+
fileData.push({
|
|
286
|
+
path: relPath,
|
|
287
|
+
file: basename(file),
|
|
288
|
+
chars: content.length,
|
|
289
|
+
tokens: tok(content.length),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Always-loaded set
|
|
294
|
+
const alwaysFiles = budget ? Object.keys(budget.alwaysLoadedFiles || {}) : [];
|
|
295
|
+
let alwaysTotal = 0;
|
|
296
|
+
let onDemandTotal = 0;
|
|
297
|
+
|
|
298
|
+
// Per-skill grouping
|
|
299
|
+
console.log(` ${"File".padEnd(48)} ${"Chars".padStart(7)} ${"Tokens".padStart(7)} ${"Type".padStart(12)}`);
|
|
300
|
+
console.log(` ${"─".repeat(48)} ${"─".repeat(7)} ${"─".repeat(7)} ${"─".repeat(12)}`);
|
|
301
|
+
|
|
302
|
+
for (const fd of fileData) {
|
|
303
|
+
const isAlways = alwaysFiles.some(a => fd.path === a || fd.path.endsWith("/" + a) || a.endsWith(fd.file));
|
|
304
|
+
const type = isAlways ? cyan("always") : dim("on-demand");
|
|
305
|
+
const flag = fd.tokens > (budget?.perFileBudget || 9999) ? red(" ⚠ over budget") : "";
|
|
306
|
+
console.log(` ${fd.path.padEnd(48)} ${String(fd.chars).padStart(7)} ${String(fd.tokens).padStart(7)} ${type}${flag}`);
|
|
307
|
+
if (isAlways) alwaysTotal += fd.tokens;
|
|
308
|
+
else onDemandTotal += fd.tokens;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
console.log(`\n ${"─".repeat(80)}`);
|
|
312
|
+
const alwaysOverBudget = alwaysTotal > (budget?.alwaysLoadedBudget || 99999);
|
|
313
|
+
console.log(` Always-loaded total: ${bold(String(alwaysTotal))} tokens ${alwaysOverBudget ? red("⚠ OVER BUDGET") : green("✓ within budget")}`);
|
|
314
|
+
console.log(` On-demand total: ${onDemandTotal} tokens`);
|
|
315
|
+
console.log(` Grand total: ${alwaysTotal + onDemandTotal} tokens`);
|
|
316
|
+
console.log(` Budget: ${budget?.alwaysLoadedBudget || "not set"} tokens (always-loaded)\n`);
|
|
317
|
+
// NOTE: previously this was a print-only check — it never called warn()/err(), so an
|
|
318
|
+
// always-loaded overflow could never fail `npm run check` even in --strict mode. Now enforced.
|
|
319
|
+
if (alwaysOverBudget) {
|
|
320
|
+
warn(`Always-loaded total (${alwaysTotal} tokens) exceeds alwaysLoadedBudget (${budget.alwaysLoadedBudget})`);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Per-file budget — also previously print-only (see the ⚠ over budget flag above); now enforced.
|
|
324
|
+
for (const fd of fileData) {
|
|
325
|
+
if (fd.tokens > (budget?.perFileBudget || 9999)) {
|
|
326
|
+
warn(`${fd.path} is ${fd.tokens} tokens, over perFileBudget (${budget.perFileBudget})`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Per-skill breakdown
|
|
331
|
+
for (const skillDir of skillDirs) {
|
|
332
|
+
const skillFiles = fileData.filter(f => f.path.startsWith(skillDir.name + "/"));
|
|
333
|
+
const skillTotal = skillFiles.reduce((s, f) => s + f.tokens, 0);
|
|
334
|
+
// Always-loaded portion of this skill
|
|
335
|
+
const skillAlways = skillFiles.filter(f => {
|
|
336
|
+
const isAlways = alwaysFiles.some(a => f.path === a || f.path.endsWith("/" + a) || a.endsWith(f.file));
|
|
337
|
+
return isAlways;
|
|
338
|
+
}).reduce((s, f) => s + f.tokens, 0);
|
|
339
|
+
// A skill folder may bundle several mutually-exclusive mode files (e.g. visual-compositor's
|
|
340
|
+
// MARKETING vs STRUCTURAL vs EDITORIAL variants are never all loaded in the same task) — such
|
|
341
|
+
// skills can declare a perSkillBudgetOverrides entry instead of inflating the global default.
|
|
342
|
+
const overrideEntry = budget?.perSkillBudgetOverrides?.[skillDir.name];
|
|
343
|
+
const overrideBudget = typeof overrideEntry === "number" ? overrideEntry : overrideEntry?.budget;
|
|
344
|
+
const effectiveBudget = overrideBudget ?? budget?.perSkillBudget ?? 99999;
|
|
345
|
+
const overBudget = skillTotal > effectiveBudget;
|
|
346
|
+
console.log(` Skill: ${skillDir.name.padEnd(20)} ${String(skillTotal).padStart(6)} total (${skillAlways} always) ${overBudget ? red("⚠ over per-skill budget") : green("✓")}`);
|
|
347
|
+
if (overBudget) {
|
|
348
|
+
warn(`${skillDir.name}/ totals ${skillTotal} tokens, over its per-skill budget (${effectiveBudget})`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return { alwaysTotal, onDemandTotal, fileData };
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const { alwaysTotal, onDemandTotal, fileData } = measureTokens();
|
|
356
|
+
|
|
357
|
+
// ── Step 5: Diff report ──
|
|
358
|
+
console.log(bold("\n── Step 4: Diff Report (skills/ vs .agents/skills/) ──\n"));
|
|
359
|
+
|
|
360
|
+
if (!existsSync(AGENTS_DIR)) {
|
|
361
|
+
warn(`Target directory ${AGENTS_DIR} does not exist yet — first deployment`);
|
|
362
|
+
} else {
|
|
363
|
+
const targetFiles = walkDir(AGENTS_DIR);
|
|
364
|
+
const srcHashes = new Map();
|
|
365
|
+
const tgtHashes = new Map();
|
|
366
|
+
|
|
367
|
+
for (const f of allFiles) {
|
|
368
|
+
srcHashes.set(relPosix(SKILLS_SRC, f), hashFile(f));
|
|
369
|
+
}
|
|
370
|
+
for (const f of targetFiles) {
|
|
371
|
+
tgtHashes.set(relPosix(AGENTS_DIR, f), hashFile(f));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
let changed = 0, added = 0, removed = 0, unchanged = 0;
|
|
375
|
+
|
|
376
|
+
for (const [relPath, srcHash] of srcHashes) {
|
|
377
|
+
const tgtHash = tgtHashes.get(relPath);
|
|
378
|
+
if (!tgtHash) {
|
|
379
|
+
console.log(` ${green("+ ADD")} ${relPath}`);
|
|
380
|
+
added++;
|
|
381
|
+
} else if (srcHash !== tgtHash) {
|
|
382
|
+
console.log(` ${yellow("~ MOD")} ${relPath}`);
|
|
383
|
+
changed++;
|
|
384
|
+
} else {
|
|
385
|
+
unchanged++;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
for (const [relPath] of tgtHashes) {
|
|
390
|
+
if (!srcHashes.has(relPath)) {
|
|
391
|
+
console.log(` ${red("- DEL")} ${relPath}`);
|
|
392
|
+
removed++;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
console.log(`\n ${dim("Summary:")} ${added} added, ${changed} changed, ${removed} removed, ${unchanged} unchanged`);
|
|
397
|
+
|
|
398
|
+
if (added === 0 && changed === 0 && removed === 0) {
|
|
399
|
+
ok("Target is up to date — no changes needed");
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Drift detection: check if .agents/ has files that differ from src AND were not just deployed
|
|
403
|
+
if (changed > 0 || removed > 0) {
|
|
404
|
+
if (!isDryRun) {
|
|
405
|
+
console.log(`\n ${dim("Note: Run with --dry-run first to review changes before deploying.")}`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Commands diff report
|
|
411
|
+
if (commandFiles.length > 0) {
|
|
412
|
+
const COMMANDS_TARGET = join(REPO_ROOT, ".agents", "commands");
|
|
413
|
+
if (!existsSync(COMMANDS_TARGET)) {
|
|
414
|
+
console.log(` ${dim("(commands/ target does not exist yet — first deployment)")}`);
|
|
415
|
+
} else {
|
|
416
|
+
const tgtCmds = readdirSync(COMMANDS_TARGET).filter(f => f.endsWith(".md"));
|
|
417
|
+
const srcCmds = commandFiles.map(f => basename(f));
|
|
418
|
+
let cmdAdded = 0, cmdChanged = 0, cmdRemoved = 0, cmdUnchanged = 0;
|
|
419
|
+
|
|
420
|
+
for (const src of srcCmds) {
|
|
421
|
+
const tgt = join(COMMANDS_TARGET, src);
|
|
422
|
+
if (!existsSync(tgt)) {
|
|
423
|
+
console.log(` ${green("+ ADD")} commands/${src}`);
|
|
424
|
+
cmdAdded++;
|
|
425
|
+
} else if (hashFile(join(COMMANDS_SRC, src)) !== hashFile(tgt)) {
|
|
426
|
+
console.log(` ${yellow("~ MOD")} commands/${src}`);
|
|
427
|
+
cmdChanged++;
|
|
428
|
+
} else {
|
|
429
|
+
cmdUnchanged++;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
for (const tgt of tgtCmds) {
|
|
434
|
+
if (!srcCmds.includes(tgt)) {
|
|
435
|
+
console.log(` ${red("- DEL")} commands/${tgt}`);
|
|
436
|
+
cmdRemoved++;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if (cmdAdded > 0 || cmdChanged > 0 || cmdRemoved > 0) {
|
|
441
|
+
console.log(` ${dim("Commands:")} ${cmdAdded} added, ${cmdChanged} changed, ${cmdRemoved} removed, ${cmdUnchanged} unchanged`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function printSummary(total = alwaysTotal) {
|
|
446
|
+
printCard({
|
|
447
|
+
title: `${c.brand}${g.brand} @shavin/skills Build ${errors > 0 ? "Failed" : "Complete"}${c.reset}`,
|
|
448
|
+
items: [
|
|
449
|
+
{ label: "Skills:", value: `${c.bold}${c.fg}${skillDirs.length} agent skill modules${c.reset}` },
|
|
450
|
+
{ label: "Specifications:", value: `${c.fg}${allFiles.length} markdown documents${c.reset}` },
|
|
451
|
+
{ label: "Always-Loaded Cap:", value: `${c.fg}${total} / ${budget?.alwaysLoadedBudget || 22000} tokens${c.reset}` },
|
|
452
|
+
{ label: "Cross-References:", value: `${fmt.pass("ALL RESOLVED")}` },
|
|
453
|
+
{ label: "Validation Status:", value: errors > 0 ? `${fmt.fail("FAILED")} (${errors} errors)` : `${fmt.pass("VERIFIED")}` },
|
|
454
|
+
],
|
|
455
|
+
footer: isDryRun
|
|
456
|
+
? `${c.fgSubtle}Dry-run mode: no files were synced to .agents/skills/.${c.reset}`
|
|
457
|
+
: `${c.fgSubtle}All agent skills and slash commands synced to .agents/skills/.${c.reset}`,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (!isDryRun && errors === 0) {
|
|
462
|
+
console.log(bold("\n── Step 5: Sync to .agents/skills/ ──\n"));
|
|
463
|
+
|
|
464
|
+
if (!existsSync(AGENTS_DIR)) {
|
|
465
|
+
mkdirSync(AGENTS_DIR, { recursive: true });
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Copy all source files, plus the helper scripts skills tell agents to run
|
|
469
|
+
// (layout-compositions/scripts/*.py); they are not measured as skill text.
|
|
470
|
+
const supportFiles = walkDir(SKILLS_SRC, ".py").filter((f) => f.endsWith(".py"));
|
|
471
|
+
let copied = 0;
|
|
472
|
+
for (const file of [...allFiles, ...supportFiles]) {
|
|
473
|
+
const relPath = relPosix(SKILLS_SRC, file);
|
|
474
|
+
const target = join(AGENTS_DIR, relPath);
|
|
475
|
+
const targetDir = dirname(target);
|
|
476
|
+
|
|
477
|
+
if (!existsSync(targetDir)) {
|
|
478
|
+
mkdirSync(targetDir, { recursive: true });
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
const srcHash = hashFile(file);
|
|
482
|
+
const tgtHash = hashFile(target);
|
|
483
|
+
|
|
484
|
+
if (srcHash !== tgtHash) {
|
|
485
|
+
copyFileSync(file, target);
|
|
486
|
+
copied++;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Remove files in target that no longer exist in source
|
|
491
|
+
if (existsSync(AGENTS_DIR)) {
|
|
492
|
+
const targetFiles = [...walkDir(AGENTS_DIR), ...walkDir(AGENTS_DIR, ".py").filter((f) => f.endsWith(".py"))];
|
|
493
|
+
for (const f of targetFiles) {
|
|
494
|
+
const relPath = relPosix(AGENTS_DIR, f);
|
|
495
|
+
const srcFile = join(SKILLS_SRC, relPath);
|
|
496
|
+
if (!existsSync(srcFile)) {
|
|
497
|
+
unlinkSync(f);
|
|
498
|
+
console.log(` ${red("- DEL")} ${relPath} (removed from target — no longer in source)`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
console.log(`\n ${green("✓ Synced")} ${copied} file(s) to ${AGENTS_DIR}`);
|
|
504
|
+
|
|
505
|
+
// Sync commands (COMMANDS_SRC declared at top with commandFiles)
|
|
506
|
+
const COMMANDS_TARGET = join(REPO_ROOT, ".agents", "commands");
|
|
507
|
+
if (existsSync(COMMANDS_SRC)) {
|
|
508
|
+
if (!existsSync(COMMANDS_TARGET)) mkdirSync(COMMANDS_TARGET, { recursive: true });
|
|
509
|
+
let cmdCopied = 0;
|
|
510
|
+
for (const cmdFile of readdirSync(COMMANDS_SRC)) {
|
|
511
|
+
if (cmdFile.endsWith(".md")) {
|
|
512
|
+
const src = join(COMMANDS_SRC, cmdFile);
|
|
513
|
+
const tgt = join(COMMANDS_TARGET, cmdFile);
|
|
514
|
+
if (hashFile(src) !== hashFile(tgt)) {
|
|
515
|
+
copyFileSync(src, tgt);
|
|
516
|
+
cmdCopied++;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (cmdCopied > 0) {
|
|
521
|
+
console.log(` ${green("✓ Synced")} ${cmdCopied} command file(s) to ${COMMANDS_TARGET}`);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// Remove orphaned command files (in target but not in source)
|
|
525
|
+
const tgtCmdFiles = readdirSync(COMMANDS_TARGET).filter(f => f.endsWith(".md"));
|
|
526
|
+
for (const f of tgtCmdFiles) {
|
|
527
|
+
const srcFile = join(COMMANDS_SRC, f);
|
|
528
|
+
if (!existsSync(srcFile)) {
|
|
529
|
+
unlinkSync(join(COMMANDS_TARGET, f));
|
|
530
|
+
console.log(` ${red("- DEL")} commands/${f} (orphaned — not in source)`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
} else if (isDryRun) {
|
|
535
|
+
console.log(bold("\n── Step 5: Sync ──\n"));
|
|
536
|
+
console.log(` ${dim("(skipped — dry run mode)")}`);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
printSummary(alwaysTotal);
|
|
540
|
+
process.exit(errors > 0 ? 1 : 0);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Add or revise a composition in the library, keeping metadata, wireframes and the selection guide consistent
|
|
3
|
+
argument-hint: <name and short description of the new composition>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Add or revise a composition in the `layout-compositions` skill: $ARGUMENTS
|
|
7
|
+
|
|
8
|
+
1. Read `references/metadata-schema.md` and one existing entry in the target family for tone and depth.
|
|
9
|
+
2. Decide the family (create a new family file only if none fits) and the next unused ID. Never reuse or renumber IDs.
|
|
10
|
+
3. Write the entry in the standard format: yaml metadata, Best for, Avoid when, Grid (with breakpoints and spans), a `wf` wireframe, Contract, Watch. Make the `Avoid when` line name the better alternative by ID.
|
|
11
|
+
4. Run `python scripts/render_wireframes.py references/compositions/<family>.md` to align the wireframe; fix any truncation warnings.
|
|
12
|
+
5. Register it: add the ID to the decision table and overview table in `references/selection-guide.md`, and to any relevant recipe in `references/page-recipes.md`. If it supports motion, add a row to `layout-motion/references/composition-motion-map.md`.
|
|
13
|
+
6. Run `python scripts/validate_library.py` and fix every error.
|
|
14
|
+
7. Summarise what changed and note any existing composition that this one overlaps with.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Apply / Configure `@shavin/ui` Theme
|
|
2
|
+
|
|
3
|
+
Automated recipe to configure theme tokens and mount the `ThemeProvider` in a consumer project.
|
|
4
|
+
|
|
5
|
+
## Input Argument
|
|
6
|
+
$ARGUMENTS (Theme Configuration: e.g., `brandColor="monochrome" grayColor="zinc" radius="large" scaling="100%"` — optional; if omitted, reads from `SHAVIN.md`)
|
|
7
|
+
|
|
8
|
+
## Instructions
|
|
9
|
+
|
|
10
|
+
### 0. Read Project Context (Source of Truth for Theme Values)
|
|
11
|
+
|
|
12
|
+
- 💡 **If `shavin-mcp` is connected:** Call `get_project_context()` — it reads `SHAVIN.md` and returns the project's current brand, gray color, theme mode, radius, scaling, and panel background. Use those values as the `ThemeProvider` props.
|
|
13
|
+
- 💡 **Otherwise (No-MCP):** Read `SHAVIN.md` directly (`view SHAVIN.md` or equivalent file read). Look for the `## 2. Design System Configuration` section for the configured values. If `SHAVIN.md` doesn't exist, use the `init` defaults (monochrome brand, zinc gray, medium radius, 95% scaling) (or the defaults below).
|
|
14
|
+
- **If `$ARGUMENTS` provides explicit theme values, those override `SHAVIN.md`** — the user is intentionally changing the theme. Update `SHAVIN.md`'s `## 2. Design System Configuration` section to reflect the new values so future sessions don't revert.
|
|
15
|
+
- **If `$ARGUMENTS` is empty and `SHAVIN.md` exists, use `SHAVIN.md`'s values — do NOT apply the template defaults below as if they were the project's intended configuration.**
|
|
16
|
+
|
|
17
|
+
### 1. Locate Root Layout or App Provider
|
|
18
|
+
Find the root entry point (e.g. `src/app/layout.tsx`, `pages/_app.tsx`, or `src/App.tsx`).
|
|
19
|
+
|
|
20
|
+
### 2. Mount `<ThemeProvider>`
|
|
21
|
+
Ensure `ThemeProvider` is imported from `@shavin/ui` and wraps the application body:
|
|
22
|
+
```tsx
|
|
23
|
+
import { ThemeProvider } from "@shavin/ui";
|
|
24
|
+
|
|
25
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
26
|
+
return (
|
|
27
|
+
<html lang="en" suppressHydrationWarning>
|
|
28
|
+
<body className="min-h-screen bg-canvas text-fg">
|
|
29
|
+
<ThemeProvider
|
|
30
|
+
brandColor="monochrome"
|
|
31
|
+
grayColor="zinc"
|
|
32
|
+
radius="medium"
|
|
33
|
+
scaling="100%"
|
|
34
|
+
panelBackground="solid"
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</ThemeProvider>
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
Vite: wrap the app in `src/main.tsx` instead: `<ThemeProvider brandColor="monochrome" …><App /></ThemeProvider>`.
|
|
44
|
+
|
|
45
|
+
> **Note:** The values above are template defaults from `SHAVIN.template.md`. Replace them with the values from `SHAVIN.md`'s `## 2. Design System Configuration` (or `$ARGUMENTS` if provided). See Step 0.
|
|
46
|
+
|
|
47
|
+
### 3. Available Theme Presets
|
|
48
|
+
- **Brand Colors**: `monochrome` (the default), another named brand colour, or a hex (`#rrggbb`). Take the colour from the brief or `SHAVIN.md`; never invent one.
|
|
49
|
+
- **Gray Colors**: `gray` (pure neutral), `zinc` (cool tech), `slate` (slate blue), `sand` (warm earth), `olive` (earth green).
|
|
50
|
+
- **Radius Presets**: `none` (0px), `small` (subtle), `medium` (standard 16px panel / 8px control), `large` (curved), `full` (pill controls).
|
|
51
|
+
- **Scaling**: `100%` (default), `95%` (dense SaaS), `90%`, `105%`, `110%`.
|
|
52
|
+
- **Panel Background**: `solid` (opaque high performance) | `translucent` (glassmorphism blur).
|
|
53
|
+
|
|
54
|
+
### 4. Verify Dark Mode Support
|
|
55
|
+
Ensure root `<html>` or `<body>` toggles the `.dark` class for seamless dual-mode token switching.
|
|
56
|
+
|
|
57
|
+
### 5. Verification
|
|
58
|
+
- 💡 **If `shavin-mcp` is connected:** Call `validate_code({ code })` on the updated layout file to verify token purity.
|
|
59
|
+
- 💡 **Otherwise (No-MCP):** Run `npm run tokens:check` and `npm run typecheck` to verify the configuration compiles cleanly.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Audit an existing page or component against the layout-compositions library and report fixes
|
|
3
|
+
argument-hint: <file path, URL, or pasted markup to audit>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Audit this page against the `layout-compositions` library: $ARGUMENTS
|
|
7
|
+
|
|
8
|
+
If it is a file or directory, read it. If it is a URL, fetch it. Then:
|
|
9
|
+
|
|
10
|
+
1. **Identify** each section and the composition (by ID) it most resembles, or note "no match". Note the treatment in use and the motion tier.
|
|
11
|
+
2. **Check each section** against that composition's `Contract`, `Grid`, `Avoid when` and `Watch` lines.
|
|
12
|
+
3. **Check the page** against `foundations.md`: measure in `ch`, concentric radii, spacing rhythm (no three consecutive identical grids), responsive behaviour and reading order, accessibility baseline (headings, landmarks, focus, contrast, reduced motion, auto-moving content), performance (LCP media, CLS, lazy loading), stress tests.
|
|
13
|
+
4. **Check distinctiveness** with `distinctiveness.md`: the sameness test and the list of common tells.
|
|
14
|
+
5. **Report** as a table sorted by severity: location · issue · why it matters · concrete fix (with the composition ID or foundation rule that applies). Separate "must fix" (accessibility, broken layout, misleading proof) from "should improve" and "consider".
|
|
15
|
+
6. End with the three highest-impact changes. Don't rewrite the page unless I ask; offer to apply the fixes.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Audit UI for `@shavin/ui` Compliance
|
|
2
|
+
|
|
3
|
+
Automated recipe to inspect existing code for token purity, accessibility, and concentric geometry compliance.
|
|
4
|
+
|
|
5
|
+
## Input Argument
|
|
6
|
+
$ARGUMENTS (Target File or Component Path, e.g., `src/components/Hero.tsx`, `src/app/page.tsx`, or `all`)
|
|
7
|
+
|
|
8
|
+
## Instructions
|
|
9
|
+
|
|
10
|
+
### 0. Read Project Context
|
|
11
|
+
- 💡 **If `shavin-mcp` is connected:** Call `get_project_context()` to confirm the project's theme configuration before auditing — this helps identify whether violations are caused by a mismatch between `SHAVIN.md`'s declared theme and the actual code.
|
|
12
|
+
- 💡 **Otherwise (No-MCP):** Read `SHAVIN.md` directly for the project's declared theme values. Compare against the code being audited.
|
|
13
|
+
|
|
14
|
+
- 💡 **MCP path:** If `shavin-mcp` is connected, prefer `shavin_steer({ action: "audit", code, filePath })` over manually re-deriving this checklist — it auto-detects domain intent, snapshots before `polish`, and returns dense pass/fail tuples. If a dev server is running and a browser tab is connected via the Bridge daemon, `get_live_audit` gives real rendered-DOM results instead of static-code analysis.
|
|
15
|
+
- 💡 **No-MCP path:** Run `node bin/lint-tokens.mjs $ARGUMENTS` — it implements the Token Purity checks below (§1) deterministically via the same regexes as `@shavin/mcp`'s `validate_code`, with `--fix` for autofixable cases (hex→token, literal radius→token; raw Tailwind color-scale utilities are flagged but not autofixed). Sections §2–§4 below (concentric nesting, typography hierarchy, icons/accessibility) require reading the code against `visual-compositor/concentric-laws.md`, `typography-rules.md`, and `core-rules.md` directly — `lint-tokens.mjs` only covers §1.
|
|
16
|
+
|
|
17
|
+
Inspect the specified code and report all violations using this checklist:
|
|
18
|
+
|
|
19
|
+
### 1. Token Purity Check (Zero Tolerance)
|
|
20
|
+
- [ ] No hardcoded hex values (`#ffffff`, `#09090b`, `#3b82f6`). Fix: replace with `bg-surface`, `text-fg`, `bg-brand`.
|
|
21
|
+
- [ ] No `rgb()` or `rgba()` literals. Fix: replace with semantic classes.
|
|
22
|
+
- [ ] No raw Tailwind color classes (`bg-blue-600`, `text-gray-500`, `border-slate-200`). Fix: replace with semantic equivalents (`bg-brand`, `text-fg-subtle`, `border-hairline`).
|
|
23
|
+
- [ ] No foundation variable references (`--n-*`). Fix: use semantic variables.
|
|
24
|
+
|
|
25
|
+
### 2. Concentric Radius Check
|
|
26
|
+
- [ ] No literal radius classes (`rounded-lg`, `rounded-xl`, `rounded-2xl`).
|
|
27
|
+
- [ ] Container surfaces (cards, dialogs, popovers) use `rounded-[var(--radius-panel)]`.
|
|
28
|
+
- [ ] Interactive controls (buttons, textfields, badges) use `rounded-[var(--radius-lg)]`.
|
|
29
|
+
- [ ] Concentric nested elements satisfy $R_{\text{inner}} = \max(\text{floor}, R_{\text{outer}} - P)$, floor = `min(radius-lg, radius-panel / 2)` (or use `rounded-panel-p3` / `rounded-panel-p5`).
|
|
30
|
+
|
|
31
|
+
### 3. Typography Hierarchy Check
|
|
32
|
+
- [ ] Headings use `text-fg`.
|
|
33
|
+
- [ ] Paired descriptions directly below titles use `text-fg-subtle` (`color="subtle"`), NEVER `text-fg-muted`.
|
|
34
|
+
- [ ] `font-mono` is restricted strictly to code snippets, API endpoints, tokens, and hashes (never on standard labels).
|
|
35
|
+
|
|
36
|
+
### 4. Icon & Accessibility Check
|
|
37
|
+
- [ ] No emoji characters in UI text.
|
|
38
|
+
- [ ] No handwritten inline `<svg><path .../></svg>` icons. All icons imported from `lucide-react`.
|
|
39
|
+
- [ ] Interactive icon buttons have explicit `aria-label` attributes.
|
|
40
|
+
|
|
41
|
+
### 5. Remediation
|
|
42
|
+
Output a concise before/after diff for each violation detected.
|