@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/AGENTS.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# @shavin/ui — Agent Rules
|
|
2
|
+
|
|
3
|
+
<!-- Written by @shavin/cli init or the MCP install_skills tool. Regenerate with `npx @shavin/skills --force`. -->
|
|
4
|
+
|
|
5
|
+
> **Start here:** read `SHAVIN.md`, this project's design brief (product, theme, site type, visual mode), at the start of every task that writes UI, follow-ups included, or call `get_project_context()` via `shavin-mcp`. The rules and skills below take their defaults from it.
|
|
6
|
+
>
|
|
7
|
+
> 💡 **MCP Guidance:** Call `get_guidelines({ section: "<topic>" })` or `get_components({ name: "<name>" })` via `shavin-mcp` to query full component tables, Radix gotchas, or ThemeProvider specs.
|
|
8
|
+
|
|
9
|
+
This project uses `@shavin/ui`: a strict two-tier token architecture, accessible React primitives, and an MCP server that grounds AI agents in the real components and tokens. Follow these rules for every UI change.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 0. UI workflow: look up, build to the rules, validate
|
|
14
|
+
|
|
15
|
+
Whenever asked to create, design, refine, iterate on, or review any component, block, screen, or page layout in this project, you MUST follow this 3-step loop. It applies to the first request and to every follow-up turn that writes UI, however small ("add a filter", "change the colour"); a small edit is not an exception.
|
|
16
|
+
|
|
17
|
+
**Components only.** Every UI element is a `@shavin/ui` component: no raw `<button>`, `<input>`, `<select>`, `<textarea>`, `<table>` or `<dialog>`, no hand-styled `<div>` standing in for a card, badge, modal, tabs or toast, and no other UI library in new code. If nothing fits, compose from `Box`, `Flex`, `Grid`, `Text`, `Heading`, `Icon` and say what is missing.
|
|
18
|
+
|
|
19
|
+
**Six states, by default.** Every screen, list, form and component covers first-time, empty, loading (`Skeleton`, never a spinner for content), error, success and disabled, without the user asking. Every site and app also has a not-found page and an error boundary. Which component per state: `CLAUDE.md` "States" or the `shavin-app` skill.
|
|
20
|
+
|
|
21
|
+
1. **Step 1 (Pre-Flight DS Lookup — No Parametric Memory Slop)**:
|
|
22
|
+
- **NEVER** invent JSX markup, prop names, or Tailwind classes from generic LLM training memory.
|
|
23
|
+
- **ALWAYS** query `@shavin/ui` primitives via `get_components({ name })` or read its entry in `components.json`.
|
|
24
|
+
- **ALWAYS** verify tokens via `get_tokens()` or `tokens.json`.
|
|
25
|
+
- When building full sections or pages, **plan first**: `plan_page({ brief })` picks a composition per section from `layout-compositions/` (57 compositions across 9 families), with treatment and motion tier; fill it, save it as `.shavin/plans/<page>.json` and run `check_page({ plan })`. Build each section as `<Section data-composition="<ID>">`, fetching its family with `get_skill({ name: "layout-compositions", section: "<family>" })`. No MCP? Use `/compose-page`.
|
|
26
|
+
|
|
27
|
+
2. **Step 2 (Anti-Slop Laws & Concentric Math)**:
|
|
28
|
+
- **Zero AI Slop**: Ban decorative floating glow balls/mesh circles, badge soup for non-state text, vacuous copywriting clichés ("Revolutionize your workflow", "It's not X. It's Y."), and excessive card borders/containment.
|
|
29
|
+
- **Strict Token Purity**: Only semantic classes (`bg-surface`, `text-fg`, `text-fg-subtle`, `border-hairline`). ZERO raw hex (`#...`), ZERO `rgb(...)`, ZERO `--n-*` foundation vars.
|
|
30
|
+
- **Concentric Radius**: Controls use `rounded-[var(--radius-lg)]`; containers use `rounded-[var(--radius-panel)]`. Inner radius must satisfy $R_{\text{inner}} = \max(\text{floor}, R_{\text{outer}} - P)$, floor $= \min(\text{radius-lg}, \text{radius-panel}/2)$.
|
|
31
|
+
- **Container Spacing**: Always wrap `Card` children in `<Flex direction="column" gap="3">` (or `space-y-3`). Never stack children flush.
|
|
32
|
+
|
|
33
|
+
3. **Step 3 (Post-Flight Validation)**:
|
|
34
|
+
- Run `validate_code({ code })` or `npm run lint` before presenting final code to ensure zero token violations or class misspellings, then `check_page({ targetDir })` so every section matches its planned composition.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 1. Core Mental Model (Two Tiers)
|
|
39
|
+
|
|
40
|
+
1. **Foundation tokens** — raw palette scale (`--n-0` through `--n-1000`) defined in `@shavin/ui`'s `global.css`. **Never reference `--n-*` outside `global.css`.**
|
|
41
|
+
2. **Semantic tokens** — role-based (`--bg-canvas`, `--fg`, `--brand`, `--hairline`), remapped per theme (`:root` = light, `.dark` = dark). **Every component uses ONLY these via Tailwind utilities** (`bg-surface`, `text-fg`, `border-hairline`) — never a raw hex, never `rgb()`, never an `--n-*` var.
|
|
42
|
+
|
|
43
|
+
To learn legal tokens, call `get_tokens()` or read `tokens.json`.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 2. Directory Layout & Imports
|
|
48
|
+
|
|
49
|
+
Everything comes from the `@shavin/ui` package root; you never need its internal folders.
|
|
50
|
+
|
|
51
|
+
| Where | What |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `@shavin/ui` | Every primitive, `ThemeProvider`, `cn`, theme presets and helpers |
|
|
54
|
+
| `@shavin/ui/server` | Server-safe helpers (`cn`, URL helpers) for React Server Components |
|
|
55
|
+
| `node_modules/@shavin/ui/components.json` | Component manifest: props, variants, examples and guidance (`get_components`) |
|
|
56
|
+
| `node_modules/@shavin/ui/tokens.json` | Semantic token dictionary (`get_tokens`) |
|
|
57
|
+
| `.agents/skills/`, `.agents/commands/` | Installed agent skills and slash commands (`npx @shavin/skills`) |
|
|
58
|
+
| `SHAVIN.md` | This project's design brief: site type, mode, brand, density, radius |
|
|
59
|
+
|
|
60
|
+
> ⚠️ **Import Rule:** ALWAYS import from `@shavin/ui`. NEVER deep import from `@shavin/ui/primitives/...`.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 3. Radix & Primitive Selection
|
|
65
|
+
|
|
66
|
+
Pick the Shavin component for the pattern; its engine is listed here so you know the behaviour you get:
|
|
67
|
+
|
|
68
|
+
| Pattern | Engine | Key Rule / Primitive |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| Modals & Palette | Radix Dialog | Focus trap, ESC, outside click. `Spotlight`, `Dialog`. |
|
|
71
|
+
| Destructive Confirm | Radix AlertDialog | Focus defaults to Cancel, no outside-click dismiss. |
|
|
72
|
+
| Select / Dropdown | Radix Select | **Gotcha:** `value: ""` forbidden (reserved sentinel). Scroll via `Select.Viewport`. |
|
|
73
|
+
| Menus & Tooltips | Radix Popover/Menu/Tooltip | `collisionPadding={8}`, `align="start"`. Tooltips take `tone="auto|dark|light"`. |
|
|
74
|
+
| Controls & Switches | Radix Checkbox/Switch/Radio | Use native ARIA states. RadioGroupItem defaults `radius="full"`. |
|
|
75
|
+
| Shapes & Avatars | Radix Avatar/Slider/Badge | Escape hatch `radius="none|small|medium|large|full|inherit"`. Badge defaults `"inherit"`. |
|
|
76
|
+
| Native-element components | Shavin wrappers over native HTML | `Dropdown` (native `<select>`), `DatePicker`, `TimePicker`. Always the Shavin component, never the raw element. |
|
|
77
|
+
|
|
78
|
+
Any floating overlay surface MUST have `data-panel` attribute for translucent panel support.
|
|
79
|
+
Chevron convention: `ChevronRight` (rotated 90° down when expanded) for nav trees; `ChevronDown` (rotated 180° up when expanded) for accordions.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 4. Concentric Radius & Spacing Rules
|
|
84
|
+
|
|
85
|
+
- **Controls (`--radius-lg`)**: Single-line inputs, buttons, badges, chips, switches. Go pill-shaped at "Full" preset (`rounded-[var(--radius-lg)]`).
|
|
86
|
+
- **Panels & Containers (`--radius-panel`)**: Cards, dialogs, popovers, menus, accordions, callouts. Intentionally capped at finite radius (`rounded-[var(--radius-panel)]`) — **NEVER** use `--radius-lg` on containers or accordions.
|
|
87
|
+
- **Concentric Nesting:** Inner radius must satisfy $R_{\text{inner}} = \max(\text{floor}, R_{\text{outer}} - P)$, floor $= \min(\text{radius-lg}, \text{radius-panel}/2)$. The floor keeps padded children from collapsing to square corners (0 only when the theme radius is 0); `concentricContainerStyle()` / `CONCENTRIC_FLOOR` apply it. Use concentric Tailwind utilities (`rounded-panel-p3`, `rounded-panel-p5`, `rounded-panel-inner`).
|
|
88
|
+
- **Tailwind Padding Scale Trap:** `p-5` is 20px (`1.25rem`), `p-3` is 12px (`0.75rem`). NEVER confuse `p-5` with 5px! Do not write inline `calc(...) - 5px` for `p-5`. Use `rounded-panel-p5`.
|
|
89
|
+
- **Literals forbidden:** Never use literal `rounded-lg`, `rounded-xl`, `rounded-2xl`. `rounded-full` allowed ONLY for pills, avatars, switches.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 5. ThemeProvider
|
|
94
|
+
|
|
95
|
+
`init` already mounts it once in the root layout; do not add a second one. Its values come from `SHAVIN.md` and `.shavin/config.json` (for example `<ThemeProvider brandColor="monochrome" grayColor="zinc" radius="medium" scaling="100%" panelBackground="solid">`). To change the brand: a preset name (`brandColor="teal"`), a custom hex on `ThemeProvider` or `ScopedThemeProvider` (`brandColor="#0f766e"`), or `npx @shavin/cli brand`; update `SHAVIN.md` and `.shavin/config.json` to match. A hex is allowed in those places only.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 6. Live DOM audit (optional)
|
|
100
|
+
|
|
101
|
+
With the dev server running, `get_live_audit({ path: "/route" })` reports live violations and contrast for the page open in a browser; `wait_for_live_clean` blocks until none remain. These tools only appear once a browser tab is connected. `shavin init` wires the bridge into the Next or Vite config; do not ask the user to start it.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 7. Pre-Flight Quality Gate
|
|
106
|
+
|
|
107
|
+
- [ ] All colors use semantic tokens (`bg-surface`, `text-fg`, `border-hairline`). Zero hex/rgb/`--n-*`.
|
|
108
|
+
- [ ] Container surfaces use `rounded-[var(--radius-panel)]`; controls use `rounded-[var(--radius-lg)]`.
|
|
109
|
+
- [ ] All floating panels have `data-panel` attribute.
|
|
110
|
+
- [ ] Typography contrast hierarchy: Title uses `text-fg`, paired description uses `text-fg-subtle` (`color="subtle"`), never `text-fg-muted`.
|
|
111
|
+
- [ ] Every element is a `@shavin/ui` component (no raw controls, no div imitations, no other UI library in new code).
|
|
112
|
+
- [ ] All six states exist: first-time, empty, loading, error, success, disabled.
|
|
113
|
+
- [ ] Imports reference `@shavin/ui` root (no deep paths).
|
|
114
|
+
- [ ] `validate_code` reports zero errors on every file changed this turn.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 8. Responsive Design & Breakpoint Overrides
|
|
119
|
+
|
|
120
|
+
Prefer layouts that adapt to their container before reaching for breakpoints:
|
|
121
|
+
|
|
122
|
+
- **App shells:** `AppFrame` with `Sidebar`; below 768px of the frame's own width the sidebar becomes a drawer and `<SidebarTrigger />` appears. Never hand-write a hamburger, a second nav copy or `hidden md:block` wrappers.
|
|
123
|
+
- **Card, stat and feature grids:** `Grid columns="auto"` with `minWidth` (and `maxColumns` to cap the track count). Not for bento or spanned layouts.
|
|
124
|
+
- **Headings:** `Heading` sizes `xl` and up are fluid. Pick the size for the widest layout; never add `md:text-*` steps.
|
|
125
|
+
- **Inside an AppFrame:** show or hide details with `shavin-frame-compact-only` / `shavin-frame-wide-only`, not viewport classes.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 9. Icons
|
|
130
|
+
|
|
131
|
+
- **NEVER** use emoji characters OR Unicode glyphs (✓, ★, →, •, ✔) in UI. Use `<Icon name="Check" size="sm" color="brand" />`; sizes and colours: `get_components({ name: "Icon" })`.
|
|
132
|
+
- Supported icon libraries: Lucide (default), Phosphor, Radix Icons, Material.
|
|
133
|
+
- Feature list pattern: `<Flex direction="row" align="center" gap="2">` with `<Icon>` + `<Text>`.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
<!-- @shavin/skills:reference -->
|
|
138
|
+
## Shavin Design System Skills & Agent Activation Guide
|
|
139
|
+
|
|
140
|
+
This project uses `@shavin/ui`. AI agents MUST load skills on demand based on the user's intent.
|
|
141
|
+
|
|
142
|
+
### Bootstrap on every UI turn
|
|
143
|
+
|
|
144
|
+
At the start of **every task that writes UI** in a Shavin project (the first message and each follow-up, however small), execute this 4-step bootstrap before producing any output. Skills already loaded earlier in the conversation do not need loading again; the rules in them still apply.
|
|
145
|
+
|
|
146
|
+
1. **Read project context** — Read `SHAVIN.md` from the project root (or call `get_project_context()` via `shavin-mcp` if connected). Extract: site type, default visual mode, brand, density, radius, panel background.
|
|
147
|
+
2. **Match the request against the Activation Matrix** below. Several rows can match: load every matching skill; for app screens (dashboard, settings, auth, onboarding, forms, tables) `shavin-app` leads. A request that matches no row is still Shavin UI: use `shavin-app` for functional UI and `shavin-webpage` for content pages, never freehand code. Pick the skill and visual mode.
|
|
148
|
+
3. **Core files (nothing is injected).** `AGENTS.md` and the MCP instructions carry the short form of the token, radius and component rules. For the full detail read `.agents/skills/core-rules.md` (tokens, radius, typography, fonts, icons, spacing); it is a file, not a skill name. Fetch these with `get_skill({ name: "visual-compositor", section: "<file>" })` when the task touches them: `cognitive-layer` (before generating a screen: states, affordances), `spacing-core` (section, flex and grid structure), `concentric-laws` (nested radius and padding), `typography-rules` (type scale, balance, tabular numbers), `layout-restraint` (one idea per section, anti-bloat), `interface-polish` (press feedback, depth recipes), `motion-and-physics` (any animation).
|
|
149
|
+
4. **Load on-demand files** per the resolved mode. Key on-demand files:
|
|
150
|
+
- `visual-compositor/anti-patterns.md` — Load whenever composing or reviewing blocks/screens. Contains 13 named AI-slop anti-patterns (AP-01–AP-13) with code examples, remediation, and a decision table. The governing principle: *prefer typographic hierarchy over decorative elements for structural labeling; reserve badges/pills/chips for stateful information only.*
|
|
151
|
+
- `visual-compositor/audit-checklist.md` — Load at the END of layout tasks for final verification.
|
|
152
|
+
- `shavin-webpage/` files — Load for marketing/landing page architecture, editorial craft, and style recipes.
|
|
153
|
+
- `layout-compositions/` — Load for any page/section layout work: 57 compositions across 9 families, selection guide, treatments, foundations, page recipes.
|
|
154
|
+
- `layout-motion/` — Load for Tier 1 restrained motion (reveals, hovers, count-ups, marquees).
|
|
155
|
+
- `layout-choreography/` — Load for Tier 2 cinematic/awwwards motion (pinned scrollytelling, scroll-scrubbed timelines, horizontal scroll, split-text reveals).
|
|
156
|
+
- `shavin-app/SKILL.md` — Load for SaaS, dashboards, data tables, settings, forms, auth, onboarding and any screen with state (it holds the six-state rule).
|
|
157
|
+
- Command files (`.agents/commands/`) — Load when the user invokes a `/create-screen`, `/create-block`, etc.
|
|
158
|
+
|
|
159
|
+
- 💡 **If `shavin-mcp` is connected:** Call `list_skills()` to enumerate all skills + headings, or `get_skill({ name, section })` to fetch targeted instructions. Call `list_commands()` to enumerate slash commands.
|
|
160
|
+
- 💡 **Otherwise (No-MCP):** Read the `.md` files directly from `.agents/skills/` and `.agents/commands/`.
|
|
161
|
+
|
|
162
|
+
### 🎯 Agent Activation Matrix (When to Load What)
|
|
163
|
+
|
|
164
|
+
| Task / Intent | Required Skill / Module | Key Directives to Enforce |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| **Marketing / Landing / Hero / Pricing / Launch** | `.agents/skills/shavin-webpage/` (`page-architecture.md`, `editorial-craft.md`, `style-recipes.md`) + `.agents/skills/layout-compositions/` | 12-section vertical reading arc, conversion copywriting formulas ("{Outcome} without {pain}"), 57 layout compositions across 9 families with metadata, selection guide, treatments, page recipes, mandatory word-by-word Tagline Reveal moment, fluid island navigation, authentic software previews (no 3D balls). |
|
|
167
|
+
| **Aesthetic Direction & Archetypes** | `.agents/skills/shavin-webpage/style-recipes.md` | Calibrate the 5 Design Dials (`visual-variance`, `motion-intensity`, `information-density`, `asset-dependence`, `brand-fidelity`). Select archetype: Linear Dark, Apple Minimal, Stripe Precision, Technical Brutalist, Vercel Monochrome. |
|
|
168
|
+
| **Layout Compositions & Page Structure** | `.agents/skills/layout-compositions/` | 57 compositions (ST, H, F, P/S/T, C/Q, G, E, D, X families) with content-based selection rules, 5 swappable treatments (carded, ruled, flat, full-bleed, open), page recipes, distinctiveness rules, `@shavin/ui` adapter. Use `/compose-page` to plan and build. |
|
|
169
|
+
| **Tier 1 Motion (Reveals, Hovers, Count-ups)** | `.agents/skills/layout-motion/` | 11 restrained motion presets using `--dur-*`, `--dist-*`, `--stagger` tokens. Scroll reveals, hover/press, tab/accordion transitions, count-ups, marquees with pause. Reduced-motion safety net via token zeroing. |
|
|
170
|
+
| **Tier 2 Cinematic / Awwwards Motion** | `.agents/skills/layout-choreography/` | Scene-based choreography: pinned scrollytelling, scroll-scrubbed timelines, horizontal-scroll sections, split-text/mask reveals, stacked cards, cursor effects, page transitions, WebGL heroes. Scene spec template with budgets and fallbacks. One signature + two supporting scenes max per page. Requires finished static layout first. |
|
|
171
|
+
| **Typography, Headlines, Numbers & Copy Measure** | `.agents/skills/visual-compositor/typography-rules.md` | Calibrated type scale snapping, mandatory `text-balance` on headings, `text-pretty` on body, `tabular-nums font-mono` on numbers/metrics, measure limit `max-w-2xl` (680px), subtle text gradients. |
|
|
172
|
+
| **Motion, Transitions, Springs & Page Reveals** | `.agents/skills/visual-compositor/motion-and-physics.md` | **The Frequency Law**: NEVER animate 100+/day keyboard actions. Animate entering/feedback only. Custom easings (`cubic-bezier(0.23, 1, 0.32, 1)`), no `ease-in`, duration < 300ms, Rauno split & stagger enter choreography (`blur(4px)` + `translateY(12px)` + `opacity`), Before/After review table. |
|
|
173
|
+
| **Tactile Polish, Anti-Box Law & Optical Centering** | `.agents/skills/visual-compositor/interface-polish.md` | `active:scale-[0.96]` on press, Anti-Box Law (proximity before containers), button icon padding offset (`icon-side = text-side - 2px`), play button triangle shift (`ml-0.5`), Lummi pastel mesh backdrops with directional scrims. |
|
|
174
|
+
| **SaaS Apps, Dashboards, Data Tables, Consoles** | `.agents/skills/shavin-app/SKILL.md` | `AppFrame`, `Sidebar`, optional high-density mode (`scaling="95%"`; the default is 100%), concentric panel-p5 nesting, all six states (first-time, empty, loading, error, success, disabled), table row actions. |
|
|
175
|
+
| **Forms, Settings, Sign-in / Sign-up, Onboarding** | `.agents/skills/shavin-app/SKILL.md` (Settings, Auth and Onboarding patterns) | `TextField` / `Select` / `Switch` with `invalid` + `errorMessage`, one Save, `AlertDialog` for destructive actions, `Stepper` for onboarding with validation per step and a skip path, `data-composition="none"` on utility screens. |
|
|
176
|
+
| **A single section or component** | `get_block_template` + `shavin-app` (app screen) or `shavin-webpage` (content section) | Same rules as pages: components only, six states, `validate_code` on every change. |
|
|
177
|
+
| **Anti-Pattern Review & AI-Slop Prevention** | `.agents/skills/visual-compositor/anti-patterns.md` | 13 named anti-patterns (AP-01–AP-13): Defensive Minimalism, Glow Balls, Stock Photos, Badge Soup, Paragraph Walls, Metric Clutter, Kitchen-Sink Bento, Status-Chip Soup, Over-Containment, Vacuous Copywriting, Lazy Placeholders, Harsh Border Glare, Sparkles Icon. Load before composing or when output "feels AI-generated". |
|
|
178
|
+
| **Designing live in Shavin Studio (a connected Studio session)** | `.agents/skills/shavin-studio/SKILL.md` | Only when `connect_studio` has paired, or when designing a block in isolation for approval: BlockNode trees, prop names, `@tablet` / `@mobile` overrides, frames, theme changes, the design-validate-approve-hand-off workflow. Not needed for writing code in this project. |
|
|
179
|
+
| **Concentric Geometry & Invariant Rules** | `.agents/skills/core-rules.md` & `concentric-laws.md` | Strict two-tier token purity, concentric radius formula $R_{\text{inner}} = \max(\text{floor}, R_{\text{outer}} - P)$, floor $= \min(\text{radius-lg}, \text{radius-panel}/2)$, Radix accessible primitives. |
|
|
180
|
+
|
|
181
|
+
Available AI slash commands in `.agents/commands/`:
|
|
182
|
+
- `/create-screen <type>` — Compose full production page layouts
|
|
183
|
+
- `/create-block <type>` — Compose a UI block; optionally register it in the Studio catalog (Phase 1: compose, Phase 2: register)
|
|
184
|
+
- `/create-primitive <name>` — Create a new accessible (WCAG 2.2 AA) primitive component in `@shavin/ui`
|
|
185
|
+
- `/create-theme <name>` — Add a new theme preset to the DS source (`THEME_PRESETS`)
|
|
186
|
+
- `/apply-theme [config]` — Configure `ThemeProvider` in a consumer project (reads `SHAVIN.md` first)
|
|
187
|
+
- `/audit-ui <path>` — Verify token purity and concentric radius compliance
|
|
188
|
+
- `/compose-page <brief>` — Plan and build a page from the layout-compositions library (plan table first, then code)
|
|
189
|
+
- `/audit-layout <path|url|markup>` — Audit an existing page against the composition library and report fixes
|
|
190
|
+
- `/add-composition <name>` — Add or revise a composition in the library
|
|
191
|
+
|
|
192
|
+
Project design config: see `SHAVIN.md` for theme, brand, density, and radius settings.
|
|
193
|
+
<!-- @shavin/skills:reference-end -->
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@shavin/skills` are recorded here. After 0.1.0, releases are versioned and described with [Changesets](https://github.com/changesets/changesets).
|
|
4
|
+
|
|
5
|
+
## 0.1.0 — first npm release
|
|
6
|
+
|
|
7
|
+
Agent skills and slash commands for @shavin/ui, installed into a project's `.agents/` folder.
|
|
8
|
+
|
|
9
|
+
### What's in it
|
|
10
|
+
|
|
11
|
+
- 7 skills (app and webpage building, layout compositions, motion and choreography, visual compositor, Studio; plus the always-loaded core rules) and 9 slash commands for common tasks. Maintainer-only skills stay in the repo and are never installed
|
|
12
|
+
- A "Theme for a new site or page" section in the font pairings guide: with colours and fonts still `UNSET`, the agent chooses them from the brief, applies them with `shavin brand`, reports the choice after the first page and offers to change it. A marketing page may run a full-bleed hero as well as a closing call to action; body text stays in the container
|
|
13
|
+
- One rule for page width, now in the always-loaded rules as well as the web page skill: every body section uses `Container size="lg"` (72rem) so all content shares one centred column with margins at 1280 and 1440; `xl` is for the nav and footer, `full` for media. `xl` never caps at a 1280px viewport, which left pages with almost no side margin
|
|
14
|
+
- `npx @shavin/skills` installs them; `--force` refreshes the marked block in `AGENTS.md`
|
|
15
|
+
- A token linter (`bin/lint-tokens.mjs`) that flags hex and raw palette colours
|
|
16
|
+
- Guidance for what `validate_code` checks and `autofix_code` fixes for concentric radius, the Studio default frame names, and the `brandSolid` and `focusRing` provider settings; a Hero by audience table and a Storefront recipe; the G6 Product Grid composition; navigation bar guidance for dropdown and mega panels (Popover disclosure, skip link, Drawer on phones)
|
|
17
|
+
- Hero titles default to `4xl`; `5xl` is for the type-only hero or a headline of four words or fewer
|
|
18
|
+
- Section labels above headings are optional, and responsive-by-design rules cover tables, button rows, and logo plus quote sections
|
|
19
|
+
|
|
20
|
+
### Also in this release
|
|
21
|
+
|
|
22
|
+
Anyone who copied Shavin from the public GitHub repository before this release should read the **Breaking** items.
|
|
23
|
+
|
|
24
|
+
- **Breaking**: skills and `AGENTS.md` use the `brand` names (`bg-brand`, `--brand`), with no `--brand-primary`. See the `@shavin/ui` entry.
|
|
25
|
+
- Bridge docs lead with `init` wiring the dev inspector into Next and Vite; agents are told not to ask users to start the bridge.
|
|
26
|
+
- The AGENTS.md section heading is in plain words; `init` still recognises the old headings.
|
|
27
|
+
- `shavin-app` six-state rule and patterns, and the Cursor rule, map each state to one component: `EmptyState`, `Button loading`, `FormField` / `FormErrorSummary`, `useToast`, `Button disabledReason`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Avinash Bussa and Shavin contributors
|
|
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,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Shavin Skills (`@shavin/skills`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Design-judgement skills for AI coding agents working with Shavin UI: the token rules, concentric geometry, typography, spacing, layout compositions, motion and the anti-slop catalogue that make agent output look designed instead of generated. Plain markdown, no runtime dependencies, and they work with or without the Shavin MCP server.
|
|
4
|
+
|
|
5
|
+
- **Docs:** https://docs.shavin.cc
|
|
6
|
+
- **Requires:** Node 22+ (for the installer and linter)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npx @shavin/skills # copies skills to .agents/skills/ and commands to .agents/commands/
|
|
12
|
+
npx @shavin/skills --force # overwrite existing files
|
|
13
|
+
npx @shavin/skills --target ./apps/web # install into another project
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`npx @shavin/cli init` offers to do this for you.
|
|
17
|
+
|
|
18
|
+
## What's inside
|
|
19
|
+
|
|
20
|
+
| Skill | Use it for |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `core-rules.md` | Always loaded: token compliance, radius roles, typography, icons, anti-slop basics |
|
|
23
|
+
| `visual-compositor/` | Spacing, typography, motion, polish, the AP-01–AP-13 anti-pattern catalogue, audit checklist |
|
|
24
|
+
| `layout-compositions/` | 57 page and section compositions across 9 families, with selection rules and page recipes |
|
|
25
|
+
| `layout-motion/`, `layout-choreography/` | Restrained UI motion, and cinematic scroll-driven scenes |
|
|
26
|
+
| `shavin-webpage/` | Marketing and landing pages |
|
|
27
|
+
| `shavin-app/` | SaaS apps, dashboards, tables, forms, settings, auth, onboarding (six states) |
|
|
28
|
+
| `shavin-studio/` | Only while a Studio session is connected, or when designing a block in isolation for approval (BlockNode trees, responsive overrides, hand-off) |
|
|
29
|
+
|
|
30
|
+
The repo also has maintainer-only skills (`shavin-core/`, `shavin-ui-qa-linter/`, `dense-compression-protocol.md`, listed in `internal.json`). They are not part of this package and are never installed into a project.
|
|
31
|
+
|
|
32
|
+
Slash commands: `/create-screen`, `/create-block`, `/create-primitive`, `/create-theme`, `/apply-theme`, `/audit-ui`, `/compose-page`, `/audit-layout`, `/add-composition`.
|
|
33
|
+
|
|
34
|
+
## Without the MCP server
|
|
35
|
+
|
|
36
|
+
Agents read the files directly from `.agents/skills/`. For token linting, the package ships a standalone checker that mirrors the MCP `validate_code` tool:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx -p @shavin/skills shavin-lint-tokens "src/**/*.tsx"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Maintainers
|
|
43
|
+
|
|
44
|
+
Edit skills here in `packages/skills/`, never in `.agents/` (compiled output). `npm run skills:check` validates cross-references, frontmatter and token budgets; `npm run skills:build` deploys.
|
|
45
|
+
|
|
46
|
+
## Licence
|
|
47
|
+
|
|
48
|
+
MIT © 2026 Avinash Bussa and Shavin contributors. See [LICENSE](./LICENSE).
|
|
49
|
+
"Shavin" and the Shavin product names are trademarks of Avinash Bussa.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// GENERATED from packages/block-schema/hex-policy.mjs by scripts/sync-hex-policy.mjs — do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* hex-policy — the ONE context-aware "no raw hex colour" rule.
|
|
4
|
+
*
|
|
5
|
+
* Shared by every checker (scripts/lint-tokens.mjs, @shavin/mcp validate_code /
|
|
6
|
+
* autofix_code / synthesize gate / steer / project audit, @shavin/cli publish,
|
|
7
|
+
* the community quality gate, evals graders). Pure, zero-dependency ESM so Node
|
|
8
|
+
* scripts, .mjs packages and TS apps can all import it.
|
|
9
|
+
* packages/skills/bin/hex-policy.mjs is a GENERATED copy (zero-dep package) —
|
|
10
|
+
* regenerate with `node scripts/sync-hex-policy.mjs`; `--check` gates drift.
|
|
11
|
+
*
|
|
12
|
+
* A `#…` hex run is a VIOLATION only when it is unmistakably a colour:
|
|
13
|
+
* 1. any hex in a CSS/SCSS source (lang "css");
|
|
14
|
+
* 2. inside a `style` prop/attribute/object on the same line;
|
|
15
|
+
* 3. a Tailwind arbitrary value: `bg-[#…]`, `fill-[#…]`, `[--x:#…]`, …;
|
|
16
|
+
* 4. the value of a colour-ish key/prop/attr: color, background(-color), bg,
|
|
17
|
+
* fill, stroke, stop-color/stopColor, border*, outline*, *shadow, any
|
|
18
|
+
* `*Color` / `*colour` key — also inside gradient()/rgba()/color-mix();
|
|
19
|
+
* 5. a standalone string literal whose whole value is a hex AND it contains
|
|
20
|
+
* an a–f letter, OR has 6/8 digits, OR is a repeated-digit grey (#000,
|
|
21
|
+
* #999), OR carries an alpha suffix (`#000/50`).
|
|
22
|
+
* NOT flagged: JSX text / human copy ("Order #1543", "Shell #4410",
|
|
23
|
+
* "Invoice #A1B2-77"), digit-only short ids ("#142") outside colour contexts,
|
|
24
|
+
* URL fragments (`href="#faq"`, `/docs#abc`, `url(#grad)`), HTML entities
|
|
25
|
+
* (`{`), markdown headings, and 5/7-digit runs (never valid colours).
|
|
26
|
+
* Opt-out stays the caller's job: `// ds-lint-disable-next-line no-hex`.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** #rgb #rgba #rrggbb #rrggbbaa — not followed by a word char / hyphen. */
|
|
30
|
+
const HEX_RE = /#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g;
|
|
31
|
+
|
|
32
|
+
/** Chars allowed right before `#` (else it's a URL fragment / id / entity). */
|
|
33
|
+
const PRE_OK = /[\s"'`[(,:={>_]/;
|
|
34
|
+
|
|
35
|
+
/** Colour-ish key/prop/attr directly assigning this value (rule 4). */
|
|
36
|
+
const COLOR_KEY_RE =
|
|
37
|
+
/(?<![\w$-])(?:[\w-]*colou?r|background[\w-]*|bg|fill|stroke|border[\w-]*|outline[\w-]*|[\w-]*shadow)\s*["']?\s*[:=]\s*\{?\s*["'`]?[^;"'`{}]*$/i;
|
|
38
|
+
|
|
39
|
+
/** Inside a CSS colour function in the same string/line. */
|
|
40
|
+
const COLOR_FN_RE = /(?:(?:linear|radial|conic)-gradient|rgba?|hsla?|color-mix)\([^)]*$/i;
|
|
41
|
+
|
|
42
|
+
/** Tailwind arbitrary value: `xxx-[…#` or `[--prop:#` / `[color:#`. */
|
|
43
|
+
const ARBITRARY_RE = /(?:-\[|(?:^|[\s"'`{])\[[\w-]+:)[^\]\s"'`]*$/;
|
|
44
|
+
|
|
45
|
+
/** `style={{ … #` / `style="… #` / `style: { … #` on the same line. */
|
|
46
|
+
const STYLE_RE = /\bstyle\s*(?:=\s*\{\{?[^}]*|=\s*["'][^"']*|:\s*\{[^}]*)$/;
|
|
47
|
+
|
|
48
|
+
/** String values passed to URL / selector-ish props are never colours. */
|
|
49
|
+
const URLISH_KEY_RE =
|
|
50
|
+
/(?:href|to|src|action|hash|anchor|link|path|url|selector|querySelector(?:All)?\(|getElementById\(|closest\()\s*[:=(]?\s*\{?\s*$/i;
|
|
51
|
+
|
|
52
|
+
/** Alpha / opacity suffix after a standalone hex: `#000/50`, `#000 / 0.4`. */
|
|
53
|
+
const ALPHA_SUFFIX_RE = /^\s*\/\s*[\d.]+%?\s*$/;
|
|
54
|
+
|
|
55
|
+
/** Find the string literal (on this line) enclosing column `col`, if any. */
|
|
56
|
+
function enclosingString(line, col) {
|
|
57
|
+
let quote = null;
|
|
58
|
+
let start = -1;
|
|
59
|
+
for (let i = 0; i < col; i++) {
|
|
60
|
+
const c = line[i];
|
|
61
|
+
if (quote) {
|
|
62
|
+
if (c === "\\") { i++; continue; }
|
|
63
|
+
if (c === quote) quote = null;
|
|
64
|
+
} else if (c === '"' || c === "'" || c === "`") {
|
|
65
|
+
quote = c;
|
|
66
|
+
start = i;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!quote) return null;
|
|
70
|
+
let end = line.length;
|
|
71
|
+
for (let i = col; i < line.length; i++) {
|
|
72
|
+
const c = line[i];
|
|
73
|
+
if (c === "\\") { i++; continue; }
|
|
74
|
+
if (c === quote) { end = i; break; }
|
|
75
|
+
}
|
|
76
|
+
return { quote, start, end, value: line.slice(start + 1, end) };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** True when a bare hex (no context) is unmistakably a colour (rule 5). */
|
|
80
|
+
export function looksLikeColorHex(hex, suffix = "") {
|
|
81
|
+
const digits = hex.replace(/^#/, "");
|
|
82
|
+
if (!/^[0-9a-fA-F]{3,8}$/.test(digits) || ![3, 4, 6, 8].includes(digits.length)) return false;
|
|
83
|
+
if (/[a-f]/i.test(digits)) return true;
|
|
84
|
+
if (digits.length === 6 || digits.length === 8) return true;
|
|
85
|
+
if (/^(\d)\1+$/.test(digits)) return true;
|
|
86
|
+
return ALPHA_SUFFIX_RE.test(suffix);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Classify one hex match on a line. Returns the reason string when it is a
|
|
91
|
+
* colour violation, or null when it is content (ids, fragments, copy).
|
|
92
|
+
*/
|
|
93
|
+
function classify(line, col, hex, lang) {
|
|
94
|
+
if (lang === "css") {
|
|
95
|
+
return /url\(\s*["']?$/i.test(line.slice(0, col)) ? null : "css";
|
|
96
|
+
}
|
|
97
|
+
const before = col > 0 ? line[col - 1] : "";
|
|
98
|
+
if (before && !PRE_OK.test(before)) return null; // `/docs#abc`, `{`, `a#b`
|
|
99
|
+
const prefix = line.slice(0, col);
|
|
100
|
+
if (/url\(\s*["']?$/i.test(prefix)) return null; // SVG `url(#grad)`
|
|
101
|
+
|
|
102
|
+
if (ARBITRARY_RE.test(prefix)) return "arbitrary-class";
|
|
103
|
+
|
|
104
|
+
const str = enclosingString(line, col);
|
|
105
|
+
const before_str = str ? line.slice(0, str.start) : prefix;
|
|
106
|
+
if (str && URLISH_KEY_RE.test(before_str)) return null; // href="#abc"
|
|
107
|
+
|
|
108
|
+
if (STYLE_RE.test(prefix)) return "style";
|
|
109
|
+
if (COLOR_KEY_RE.test(prefix)) return "color-key";
|
|
110
|
+
if (str && COLOR_FN_RE.test(line.slice(str.start + 1, col))) return "color-fn";
|
|
111
|
+
|
|
112
|
+
if (str) {
|
|
113
|
+
const value = str.value;
|
|
114
|
+
const offset = col - (str.start + 1);
|
|
115
|
+
const lead = value.slice(0, offset);
|
|
116
|
+
const rest = value.slice(offset + hex.length);
|
|
117
|
+
if (lead.trim() === "" && (rest.trim() === "" || ALPHA_SUFFIX_RE.test(rest))) {
|
|
118
|
+
return looksLikeColorHex(hex, rest) ? "standalone" : null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return null; // JSX text / human copy / prose
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Find raw-hex COLOUR violations in source text.
|
|
126
|
+
* @param {string} source code (one line or a whole file)
|
|
127
|
+
* @param {{ lang?: "css" | "js", filename?: string }} [opts]
|
|
128
|
+
* @returns {{ hex: string, index: number, line: number, reason: string }[]}
|
|
129
|
+
*/
|
|
130
|
+
export function findHexViolations(source, opts = {}) {
|
|
131
|
+
const lang =
|
|
132
|
+
opts.lang ?? (opts.filename && /\.(?:css|scss|sass|less|pcss)$/i.test(opts.filename) ? "css" : "js");
|
|
133
|
+
const out = [];
|
|
134
|
+
const lines = String(source ?? "").split("\n");
|
|
135
|
+
let base = 0;
|
|
136
|
+
for (let ln = 0; ln < lines.length; ln++) {
|
|
137
|
+
const line = lines[ln];
|
|
138
|
+
HEX_RE.lastIndex = 0;
|
|
139
|
+
let m;
|
|
140
|
+
while ((m = HEX_RE.exec(line))) {
|
|
141
|
+
const reason = classify(line, m.index, m[0], lang);
|
|
142
|
+
if (reason) out.push({ hex: m[0], index: base + m.index, line: ln + 1, reason });
|
|
143
|
+
}
|
|
144
|
+
base += line.length + 1;
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Convenience: the flagged hex strings (dupes kept, source order). */
|
|
150
|
+
export function matchHexColors(source, opts) {
|
|
151
|
+
return findHexViolations(source, opts).map((v) => v.hex);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Convenience: does the source contain at least one hex colour violation? */
|
|
155
|
+
export function hasHexViolation(source, opts) {
|
|
156
|
+
return findHexViolations(source, opts).length > 0;
|
|
157
|
+
}
|