@archetypeai/ds-cli 0.3.9 → 0.3.10

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/files/AGENTS.md CHANGED
@@ -28,7 +28,6 @@ Standard Tailwind is fine for:
28
28
 
29
29
  - Spacing/sizing: `p-4`, `w-full`, `gap-2`, `h-screen`
30
30
  - Layout: `flex`, `grid`, `absolute`, `relative`
31
- - One-off colors: gradients, illustrations, custom accents
32
31
 
33
32
  ## CSS Import Order
34
33
 
@@ -49,15 +48,32 @@ Standard Tailwind is fine for:
49
48
 
50
49
  Read these when relevant to your task:
51
50
 
52
- - `@skills/apply-ds` - setup tokens in new project
51
+ - `@skills/apply-ds` - apply DS tokens, components, and patterns to an existing demo
53
52
  - `@skills/build-pattern` - create composite patterns from primitives
54
53
  - `@skills/setup-chart` - set up charts with layerchart
55
54
  - `@skills/create-dashboard` - scaffold a full-viewport dashboard with menubar and panels
56
55
  - `@skills/fix-accessibility` - audit and fix a11y issues
57
56
  - `@skills/fix-metadata` - update page titles, favicons, and OG tags
58
57
  - `@skills/deploy-worker` - deploy SvelteKit projects to Cloudflare Workers
59
- - `@skills/explain-code` - explain code with structure and traced execution
58
+ - `@skills/embedding-from-file` - run an Embedding Lens by streaming sensor data from a CSV file
59
+ - `@skills/embedding-from-sensor` - run an Embedding Lens by streaming real-time data from a physical sensor
60
+ - `@skills/embedding-upload` - run an Embedding Lens by uploading a CSV file for server-side processing
61
+ - `@skills/newton-activity-monitor-lens-on-video` - analyze uploaded video files using Newton's activity monitor lens
62
+ - `@skills/newton-camera-frame-analysis` - live webcam frame analysis using Newton's vision model
63
+ - `@skills/newton-direct-query` - simple direct query to Newton model using the /query API endpoint
64
+ - `@skills/newton-machine-state-from-file` - run a Machine State Lens by streaming sensor data from a CSV file
65
+ - `@skills/newton-machine-state-from-sensor` - run a Machine State Lens by streaming real-time data from a physical sensor
66
+ - `@skills/newton-machine-state-upload` - run a Machine State Lens by uploading a CSV file for server-side processing
60
67
 
61
68
  ## Rules
62
69
 
63
70
  See `@rules/` for comprehensive guidance on design principles, components, styling, charts, and linting.
71
+
72
+ - `@rules/accessibility` — a11y guidelines and ARIA patterns
73
+ - `@rules/charts` — chart setup, layerchart conventions, data visualization
74
+ - `@rules/components` — component API patterns, props, variants, slots
75
+ - `@rules/design-principles` — visual design language, spacing, typography
76
+ - `@rules/frontend-architecture` — component decomposition, page composition, API logic extraction
77
+ - `@rules/linting` — linting and formatting rules
78
+ - `@rules/state` — state management with Svelte 5 runes
79
+ - `@rules/styling` — Tailwind v4, semantic tokens, theming
package/files/CLAUDE.md CHANGED
@@ -28,7 +28,6 @@ Standard Tailwind is fine for:
28
28
 
29
29
  - Spacing/sizing: `p-4`, `w-full`, `gap-2`, `h-screen`
30
30
  - Layout: `flex`, `grid`, `absolute`, `relative`
31
- - One-off colors: gradients, illustrations, custom accents
32
31
 
33
32
  ## CSS Import Order
34
33
 
@@ -47,17 +46,36 @@ Standard Tailwind is fine for:
47
46
 
48
47
  ## Skills
49
48
 
49
+ **Skill composition:** When building a demo that uses a Newton or Embedding API skill, also consult `@skills/create-dashboard` for dashboard layouts and `@skills/build-pattern` for extracting components. Only include chart components (SensorChart, ScatterChart) if the user's request involves time-series or explicitly mentions charts.
50
+
50
51
  Read these when relevant to your task:
51
52
 
52
- - `@skills/apply-ds` - setup tokens in new project
53
+ - `@skills/apply-ds` - apply DS tokens, components, and patterns to an existing demo
53
54
  - `@skills/build-pattern` - create composite patterns from primitives
54
55
  - `@skills/setup-chart` - set up charts with layerchart
55
56
  - `@skills/create-dashboard` - scaffold a full-viewport dashboard with menubar and panels
56
57
  - `@skills/fix-accessibility` - audit and fix a11y issues
57
58
  - `@skills/fix-metadata` - update page titles, favicons, and OG tags
58
59
  - `@skills/deploy-worker` - deploy SvelteKit projects to Cloudflare Workers
59
- - `@skills/explain-code` - explain code with structure and traced execution
60
+ - `@skills/embedding-from-file` - run an Embedding Lens by streaming sensor data from a CSV file
61
+ - `@skills/embedding-from-sensor` - run an Embedding Lens by streaming real-time data from a physical sensor
62
+ - `@skills/embedding-upload` - run an Embedding Lens by uploading a CSV file for server-side processing
63
+ - `@skills/newton-activity-monitor-lens-on-video` - analyze uploaded video files using Newton's activity monitor lens
64
+ - `@skills/newton-camera-frame-analysis` - live webcam frame analysis using Newton's vision model
65
+ - `@skills/newton-direct-query` - simple direct query to Newton model using the /query API endpoint
66
+ - `@skills/newton-machine-state-from-file` - run a Machine State Lens by streaming sensor data from a CSV file
67
+ - `@skills/newton-machine-state-from-sensor` - run a Machine State Lens by streaming real-time data from a physical sensor
68
+ - `@skills/newton-machine-state-upload` - run a Machine State Lens by uploading a CSV file for server-side processing
60
69
 
61
70
  ## Rules
62
71
 
63
72
  See `@rules/` for comprehensive guidance on design principles, components, styling, charts, and linting.
73
+
74
+ - `@rules/accessibility` — a11y guidelines and ARIA patterns
75
+ - `@rules/charts` — chart setup, layerchart conventions, data visualization
76
+ - `@rules/components` — component API patterns, props, variants, slots
77
+ - `@rules/design-principles` — visual design language, spacing, typography
78
+ - `@rules/frontend-architecture` — component decomposition, page composition, API logic extraction
79
+ - `@rules/linting` — linting and formatting rules
80
+ - `@rules/state` — state management with Svelte 5 runes
81
+ - `@rules/styling` — Tailwind v4, semantic tokens, theming
@@ -205,10 +205,59 @@ For custom interactive elements, ensure:
205
205
  >
206
206
  ```
207
207
 
208
+ ## Page Structure
209
+
210
+ ### Skip Link
211
+
212
+ Every page should have a skip link as the first focusable element:
213
+
214
+ ```svelte
215
+ <a
216
+ href="#main-content"
217
+ class="sr-only focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50 focus:rounded-md focus:bg-background focus:px-4 focus:py-2 focus:text-foreground focus:ring-2 focus:ring-ring"
218
+ >
219
+ Skip to content
220
+ </a>
221
+
222
+ <main id="main-content">
223
+ <!-- page content -->
224
+ </main>
225
+ ```
226
+
227
+ ### Semantic Landmarks
228
+
229
+ Use semantic HTML elements instead of generic `<div>` wrappers:
230
+
231
+ ```svelte
232
+ <!-- Before -->
233
+ <div class="header">...</div>
234
+ <div class="nav">...</div>
235
+ <div class="content">...</div>
236
+
237
+ <!-- After -->
238
+ <header>...</header>
239
+ <nav>...</nav>
240
+ <main id="main-content">...</main>
241
+ ```
242
+
243
+ ### Heading Hierarchy
244
+
245
+ Every page needs an `<h1>`. If the visual design doesn't include one, add it as screen-reader-only:
246
+
247
+ ```svelte
248
+ <h1 class="sr-only">Dashboard</h1>
249
+ ```
250
+
251
+ Never skip heading levels (e.g. `<h1>` → `<h3>`). Use the correct level for the document outline.
252
+
208
253
  ## Checklist
209
254
 
210
255
  When building components, verify:
211
256
 
257
+ - [ ] Page has a skip-to-content link as the first focusable element
258
+ - [ ] Page uses semantic landmarks (`<main>`, `<header>`, `<nav>`)
259
+ - [ ] Page has an `<h1>` (visible or `sr-only`)
260
+ - [ ] Heading hierarchy doesn't skip levels
212
261
  - [ ] Icon-only buttons have `aria-label`
213
262
  - [ ] Decorative icons have `aria-hidden="true"`
214
263
  - [ ] Interactive groups have `aria-label`
@@ -0,0 +1,77 @@
1
+ ---
2
+ paths:
3
+ - '**/routes/**/*.svelte'
4
+ - '**/+page.svelte'
5
+ - '**/+layout.svelte'
6
+ ---
7
+
8
+ # Frontend Architecture
9
+
10
+ When building a page that involves more than a simple static layout, decompose it into components rather than writing a monolithic `+page.svelte`.
11
+
12
+ ## When to extract a component
13
+
14
+ Extract a component when a section of UI has:
15
+
16
+ - 3+ primitives composed together (Card + Badge + Button = a status card)
17
+ - Its own reactive state (`$state`, `$derived`)
18
+ - Potential for reuse across pages or skills
19
+
20
+ Common extraction candidates: media inputs, status displays, result/summary views, streaming logs, file upload flows.
21
+
22
+ ## Gold-standard references
23
+
24
+ The project includes pattern components that demonstrate these conventions. Study them before building new ones:
25
+
26
+ - `$lib/components/ui/VideoPlayer.svelte` — media playback with controls, composes Card + AspectRatio + Button + Slider
27
+ - `$lib/components/ui/ExpandableLog.svelte` — streaming log display, composes Collapsible + Item + Badge
28
+ - `$lib/components/ui/StatusBadge.svelte` — health indicator with derived state, composes Badge + Avatar
29
+ - `$lib/components/ui/HealthscoreCard.svelte` — score card with derived state, composes Card sub-components
30
+ - `$lib/components/ui/Menubar.svelte` — branded header with snippet slots
31
+
32
+ Check if an existing pattern fits before building a new one. Use `@skills/build-pattern` to create new patterns that follow these same conventions.
33
+
34
+ ## Component conventions
35
+
36
+ Follow `@rules/components` for the full conventions. The essentials:
37
+
38
+ - `let { class: className, ...restProps } = $props();`
39
+ - `cn()` for all class merging — never raw string concatenation
40
+ - `$derived` for computed state
41
+ - Spread `...restProps` on the root element
42
+ - Compose from DS primitives (Card, Badge, Button, etc.) — not raw HTML
43
+
44
+ ## Page-level orchestration
45
+
46
+ `+page.svelte` is the orchestrator. It should:
47
+
48
+ - Own flow state (status, session IDs, error messages)
49
+ - Import and compose child components
50
+ - Pass data down via props
51
+ - Handle top-level layout (using `@skills/create-dashboard` for dashboard layouts)
52
+
53
+ Components should be presentational where possible — receive data via props, emit events up.
54
+
55
+ ## API and streaming logic extraction
56
+
57
+ SSE consumers, fetch wrappers, polling loops, and data transforms belong in a utility file, not inline in components or pages:
58
+
59
+ ```
60
+ src/lib/api/activity-monitor.js — SSE + session management
61
+ src/lib/api/machine-state.js — streaming + windowing
62
+ src/lib/api/embeddings.js — upload + embedding extraction
63
+ ```
64
+
65
+ This keeps components focused on rendering and makes API logic testable and reusable.
66
+
67
+ ## Streaming UI
68
+
69
+ For skills that stream results (SSE, polling), prefer:
70
+
71
+ - Progressive rendering — show results as they arrive, don't wait for completion
72
+ - Live counters or progress indicators
73
+ - Auto-scrolling log views (reference ExpandableLog pattern)
74
+
75
+ ## Override clause
76
+
77
+ If the user explicitly requests a single-file prototype, a minimal example, or specifies a different structure, follow their instruction. These guidelines apply to production-quality demos, not quick experiments.
@@ -1,117 +1,129 @@
1
1
  ---
2
2
  name: apply-ds
3
- description: Sets up an existing SvelteKit project with the Archetype AI design system (@archetypeai/ds-lib-tokens). Use when initializing a new project with the design system by adding tokens to an existing project, configuring Tailwind v4 CSS imports, setting up shadcn-svelte, installing design system components and configuring eslint/prettier for Svelte projects.
3
+ description: Apply DS tokens, components, and patterns to an existing demo initialized with ds-cli init.
4
+ allowed-tools: Read, Edit, Grep, Bash
4
5
  ---
5
6
 
6
- # Applying the Design System
7
+ # Applying the Design System to a Demo
7
8
 
8
- Setup involves these steps:
9
+ This skill assumes `npx @archetypeai/ds-cli init` has already been run. The project has tokens, Tailwind v4, shadcn-svelte, and DS components installed. The goal is to migrate the demo's existing UI to use DS primitives and semantic tokens.
9
10
 
10
- 1. Install tokens package
11
- 2. Install and configure Tailwind CSS
12
- 3. Initialize shadcn-svelte
13
- 4. Install design system components
14
- 5. Configure CSS imports
15
- 6. Set up linting and formatting
11
+ ## Steps
16
12
 
17
- ## Automated Setup
13
+ 1. Audit for non-DS patterns
14
+ 2. Replace raw colors with semantic tokens
15
+ 3. Replace native elements with DS components
16
+ 4. Apply layout patterns
17
+ 5. Set up linting and formatting
18
+ 6. Verify
18
19
 
19
- Run the setup script from the project root:
20
+ ## Step 1: Audit for Non-DS Patterns
20
21
 
21
- ```bash
22
- bash scripts/setup.sh
23
- ```
24
-
25
- The script requires:
22
+ Run the `scripts/audit.sh` script located in this skill's directory from the project root. The script scans all `.svelte` files and reports:
26
23
 
27
- - A global CSS file at `src/app.css`, `src/routes/layout.css`, or `src/app.pcss`
24
+ - **Raw Tailwind colors** utilities like `bg-gray-100`, `text-blue-500`, `border-red-300` that should be semantic tokens
25
+ - **Native HTML elements** — `<button>`, `<input>`, `<table>`, `<select>`, `<textarea>`, `<dialog>`, `<hr>` that have DS component equivalents
26
+ - **Hardcoded colors** — inline `color:`, `background:`, `background-color:`, `border-color:` style values
27
+ - **Class concatenation** — string templates or `+` concatenation on class attributes instead of `cn()`
28
28
 
29
- ## Manual Setup
29
+ Review the output to prioritize what to migrate.
30
30
 
31
- ### Step 1: Install Tokens
31
+ ## Step 2: Replace Raw Colors with Semantic Tokens
32
32
 
33
- ```bash
34
- npm i @archetypeai/ds-lib-tokens
35
- ```
36
-
37
- ### Step 2: Install and Configure Tailwind CSS
38
-
39
- Install Tailwind CSS v4 and its Vite plugin:
40
-
41
- ```bash
42
- npm i -D tailwindcss @tailwindcss/vite
43
- ```
33
+ Replace raw Tailwind color utilities with semantic equivalents throughout `.svelte` files:
44
34
 
45
- Then add the `@tailwindcss/vite` plugin to your `vite.config.js`:
35
+ | Raw Tailwind | Semantic Token |
36
+ | --- | --- |
37
+ | `bg-white` | `bg-background` |
38
+ | `bg-black` | `bg-foreground` |
39
+ | `text-black` | `text-foreground` |
40
+ | `text-white` | `text-background` |
41
+ | `bg-gray-50`, `bg-gray-100` | `bg-muted` |
42
+ | `text-gray-500`, `text-gray-600` | `text-muted-foreground` |
43
+ | `bg-gray-200`, `bg-gray-300` | `bg-accent` |
44
+ | `border-gray-200`, `border-gray-300` | `border-border` |
45
+ | `bg-slate-900`, `bg-gray-900` | `bg-primary` |
46
+ | `text-slate-900`, `text-gray-900` | `text-primary` |
47
+ | `bg-red-*` | `bg-destructive` |
48
+ | `text-red-*` | `text-destructive` |
49
+ | `bg-green-*` | `bg-atai-good` |
50
+ | `text-green-*` | `text-atai-good` |
51
+ | `bg-yellow-*` | `bg-atai-warning` |
52
+ | `text-yellow-*` | `text-atai-warning` |
53
+ | `bg-blue-*` | `bg-atai-neutral` |
54
+ | `text-blue-*` | `text-atai-neutral` |
46
55
 
47
- ```js
48
- import tailwindcss from '@tailwindcss/vite';
56
+ Use judgement — not every raw color maps 1:1. Context matters:
49
57
 
50
- export default defineConfig({
51
- plugins: [svelte(), tailwindcss()]
52
- // ...
53
- });
54
- ```
58
+ - A `bg-gray-100` card background → `bg-card` or `bg-muted`
59
+ - A `bg-gray-100` hover state → `bg-accent`
60
+ - A `text-gray-400` placeholder → `text-muted-foreground`
61
+ - A `border-gray-200` divider → `border-border`
55
62
 
56
- The setup script handles this automatically — it detects your vite config file, adds the import, and inserts `tailwindcss()` into the plugins array.
63
+ Leave non-color utilities (`p-4`, `flex`, `rounded-lg`, etc.) unchanged.
57
64
 
58
- ### Step 3: Initialize shadcn-svelte
65
+ ## Step 3: Replace Native Elements with DS Components
59
66
 
60
- The `--css` flag should point to your project's global CSS file:
67
+ Swap native HTML elements for their DS component equivalents. Add imports as needed.
61
68
 
62
- ```bash
63
- npx shadcn-svelte@latest init \
64
- --base-color slate \
65
- --css src/app.css \
66
- --components-alias '$lib/components' \
67
- --lib-alias '$lib' \
68
- --utils-alias '$lib/utils' \
69
- --hooks-alias '$lib/hooks' \
70
- --ui-alias '$lib/components/ui' \
71
- --skip-preflight \
72
- --no-deps
73
- ```
69
+ | Native Element | DS Component | Import From |
70
+ | --- | --- | --- |
71
+ | `<button>` | `<Button>` | `$lib/components/ui/button` |
72
+ | `<input>` | `<Input>` | `$lib/components/ui/input` |
73
+ | `<textarea>` | `<Textarea>` | `$lib/components/ui/textarea` |
74
+ | `<select>` | `<Select.Root>` + `<Select.Trigger>` + `<Select.Content>` + `<Select.Item>` | `$lib/components/ui/select` |
75
+ | `<table>` | `<Table.Root>` + `<Table.Header>` + `<Table.Row>` + `<Table.Head>` + `<Table.Body>` + `<Table.Cell>` | `$lib/components/ui/table` |
76
+ | `<dialog>` | `<Dialog.Root>` + `<Dialog.Content>` + `<Dialog.Header>` + `<Dialog.Title>` | `$lib/components/ui/dialog` |
77
+ | `<hr>` | `<Separator>` | `$lib/components/ui/separator` |
78
+ | `<label>` | `<Label>` | `$lib/components/ui/label` |
79
+ | `<a>` (styled as button) | `<Button variant="link">` or `<Button>` with `href` | `$lib/components/ui/button` |
74
80
 
75
- ### Step 4: Install Components
81
+ For each replacement:
76
82
 
77
- Install all components:
83
+ 1. Add the import to the `<script>` block
84
+ 2. Replace the element and map attributes (`class` → `class`, `onclick` → `onclick`, etc.)
85
+ 3. Use `cn()` from `$lib/utils.js` for merging classes — never raw concatenation
86
+ 4. Map native variants: e.g. a small styled button → `<Button size="sm">`, a ghost-styled button → `<Button variant="ghost">`
78
87
 
79
- ```bash
80
- npx @archetypeai/ds-cli add ds-ui-svelte
81
- ```
88
+ ## Step 4: Apply Layout Patterns
82
89
 
83
- Or install individually:
90
+ Identify structural opportunities to use DS composition patterns:
84
91
 
85
- ```bash
86
- npx shadcn-svelte@latest add https://design-system.archetypeai.workers.dev/r/button.json
87
- ```
92
+ - **Cards** — wrap content sections in `<Card.Root>` / `<Card.Header>` / `<Card.Content>` instead of raw `<div>` with border/shadow classes
93
+ - **Separators** — replace `<hr>` or border-bottom hacks with `<Separator>`
94
+ - **Badges** — replace styled `<span>` status indicators with `<Badge>`
95
+ - **Skeleton** — replace loading placeholders with `<Skeleton>`
96
+ - **Scroll Area** — replace overflow containers with `<ScrollArea>`
97
+ - **Tooltips** — replace `title` attributes with `<Tooltip.Root>` / `<Tooltip.Trigger>` / `<Tooltip.Content>`
88
98
 
89
- ### Step 5: Configure CSS Imports
99
+ Import patterns from `$lib/components/ui/` as needed.
90
100
 
91
- Replace the contents of your global CSS file with:
101
+ ## Step 5: Set Up Linting and Formatting
92
102
 
93
- ```css
94
- @import '@archetypeai/ds-lib-tokens/theme.css';
95
- @import 'tailwindcss';
96
- ```
103
+ Run the `scripts/setup.sh` script located in this skill's directory from the project root. The script:
97
104
 
98
- ### Step 6: Set Up Linting
105
+ - Installs `eslint`, `prettier`, `eslint-plugin-svelte`, `eslint-config-prettier`, `prettier-plugin-svelte`, `prettier-plugin-tailwindcss`, and `globals`
106
+ - Creates `eslint.config.js` (flat config v9+) if it doesn't exist
107
+ - Creates `.prettierrc` with Svelte + Tailwind plugin config if it doesn't exist
108
+ - Creates `.prettierignore` if it doesn't exist
109
+ - Adds `lint`, `lint:fix`, `format`, and `format:check` scripts to `package.json`
99
110
 
100
- Install dependencies:
111
+ After setup, run linting and formatting:
101
112
 
102
113
  ```bash
103
- npm i -D eslint prettier eslint-plugin-svelte eslint-config-prettier prettier-plugin-svelte prettier-plugin-tailwindcss globals
114
+ npm run lint:fix && npm run format
104
115
  ```
105
116
 
106
- The setup script creates `eslint.config.js`, `.prettierrc`, and `.prettierignore` automatically. See `@rules/linting.md` for details.
117
+ See `@rules/linting.md` for details.
107
118
 
108
- ## Verification
119
+ ## Step 6: Verify
109
120
 
110
- Confirm setup is complete:
121
+ Confirm the design system is properly applied:
111
122
 
112
- - [ ] `@archetypeai/ds-lib-tokens` in package.json
113
- - [ ] `tailwindcss` and `@tailwindcss/vite` in package.json devDependencies
114
- - [ ] `vite.config.js` includes `import tailwindcss from '@tailwindcss/vite'` and `tailwindcss()` in plugins
115
- - [ ] `components.json` exists
116
- - [ ] Components in `$lib/components/ui/`
117
- - [ ] CSS file contains correct imports
123
+ - [ ] No raw Tailwind color utilities in `.svelte` files (re-run the audit script)
124
+ - [ ] Native elements replaced with DS components where appropriate
125
+ - [ ] All component imports resolve to `$lib/components/ui/`
126
+ - [ ] `cn()` used for class merging — no string concatenation
127
+ - [ ] Linting passes: `npm run lint && npm run format:check`
128
+ - [ ] App builds without errors: `npm run build`
129
+ - [ ] App runs correctly: `npm run dev`
@@ -0,0 +1,169 @@
1
+ #!/bin/bash
2
+ #
3
+ # Design System Audit Script
4
+ #
5
+ # Scans .svelte files for non-DS patterns that should be migrated:
6
+ # - Raw Tailwind color utilities (should be semantic tokens)
7
+ # - Native HTML elements (should be DS components)
8
+ # - Hardcoded inline color styles
9
+ # - Class string concatenation (should use cn())
10
+ #
11
+ # Usage: bash <skill-dir>/scripts/audit.sh
12
+ #
13
+
14
+ set -e
15
+
16
+ # Colors for output
17
+ RED='\033[0;31m'
18
+ YELLOW='\033[0;33m'
19
+ CYAN='\033[0;36m'
20
+ NC='\033[0m'
21
+
22
+ echo "═══════════════════════════════════════════════════"
23
+ echo " Design System Audit"
24
+ echo "═══════════════════════════════════════════════════"
25
+ echo ""
26
+
27
+ if [ ! -d "src" ]; then
28
+ echo "✗ Error: No src/ directory found"
29
+ echo " Run this script from your project root directory"
30
+ exit 1
31
+ fi
32
+
33
+ SVELTE_FILES=$(find src -name "*.svelte" -not -path "*/node_modules/*" -not -path "*/.svelte-kit/*" 2>/dev/null)
34
+
35
+ if [ -z "$SVELTE_FILES" ]; then
36
+ echo "✗ No .svelte files found in src/"
37
+ exit 1
38
+ fi
39
+
40
+ FILE_COUNT=$(echo "$SVELTE_FILES" | wc -l | tr -d ' ')
41
+ echo "Scanning $FILE_COUNT .svelte files..."
42
+ echo ""
43
+
44
+ ISSUES=0
45
+
46
+ # ─────────────────────────────────────────────────────────
47
+ # 1. Raw Tailwind color utilities
48
+ # ─────────────────────────────────────────────────────────
49
+
50
+ echo -e "${CYAN}── Raw Tailwind Colors ──${NC}"
51
+ echo ""
52
+
53
+ RAW_COLOR_PATTERN='\b(bg|text|border|ring|outline|shadow|from|to|via)-(red|blue|green|yellow|orange|purple|pink|indigo|violet|teal|cyan|emerald|amber|lime|rose|fuchsia|sky|stone|zinc|neutral|slate|gray|grey|white|black)-[0-9]'
54
+
55
+ RAW_MATCHES=$(grep -rn --include="*.svelte" -E "$RAW_COLOR_PATTERN" src/ 2>/dev/null || true)
56
+
57
+ if [ -n "$RAW_MATCHES" ]; then
58
+ echo "$RAW_MATCHES" | while IFS= read -r line; do
59
+ echo -e " ${YELLOW}$line${NC}"
60
+ done
61
+ RAW_COUNT=$(echo "$RAW_MATCHES" | wc -l | tr -d ' ')
62
+ ISSUES=$((ISSUES + RAW_COUNT))
63
+ echo ""
64
+ echo " Found $RAW_COUNT raw color utilities → replace with semantic tokens"
65
+ else
66
+ echo " ✓ No raw Tailwind color utilities found"
67
+ fi
68
+
69
+ # Also check bg-white, bg-black, text-white, text-black without shade numbers
70
+ BW_PATTERN='\b(bg-white|bg-black|text-white|text-black)\b'
71
+ BW_MATCHES=$(grep -rn --include="*.svelte" -E "$BW_PATTERN" src/ 2>/dev/null || true)
72
+
73
+ if [ -n "$BW_MATCHES" ]; then
74
+ echo ""
75
+ echo "$BW_MATCHES" | while IFS= read -r line; do
76
+ echo -e " ${YELLOW}$line${NC}"
77
+ done
78
+ BW_COUNT=$(echo "$BW_MATCHES" | wc -l | tr -d ' ')
79
+ echo ""
80
+ echo " Found $BW_COUNT black/white utilities → replace with bg-background, text-foreground, etc."
81
+ fi
82
+
83
+ echo ""
84
+
85
+ # ─────────────────────────────────────────────────────────
86
+ # 2. Native HTML elements with DS equivalents
87
+ # ─────────────────────────────────────────────────────────
88
+
89
+ echo -e "${CYAN}── Native HTML Elements ──${NC}"
90
+ echo ""
91
+
92
+ # Search in template sections only (outside <script> blocks)
93
+ NATIVE_ELEMENTS="<button[> ]|<input[> /]|<textarea[> /]|<select[> ]|<table[> ]|<dialog[> ]|<hr[> /]|<hr>"
94
+
95
+ NATIVE_MATCHES=$(grep -rn --include="*.svelte" -E "$NATIVE_ELEMENTS" src/ 2>/dev/null | grep -v '<script' | grep -v 'import ' || true)
96
+
97
+ if [ -n "$NATIVE_MATCHES" ]; then
98
+ echo "$NATIVE_MATCHES" | while IFS= read -r line; do
99
+ echo -e " ${YELLOW}$line${NC}"
100
+ done
101
+ NATIVE_COUNT=$(echo "$NATIVE_MATCHES" | wc -l | tr -d ' ')
102
+ ISSUES=$((ISSUES + NATIVE_COUNT))
103
+ echo ""
104
+ echo " Found $NATIVE_COUNT native elements → replace with DS components"
105
+ else
106
+ echo " ✓ No native HTML elements with DS equivalents found"
107
+ fi
108
+
109
+ echo ""
110
+
111
+ # ─────────────────────────────────────────────────────────
112
+ # 3. Hardcoded inline color styles
113
+ # ─────────────────────────────────────────────────────────
114
+
115
+ echo -e "${CYAN}── Hardcoded Inline Colors ──${NC}"
116
+ echo ""
117
+
118
+ INLINE_PATTERN='style="[^"]*\b(color|background|background-color|border-color)\s*:'
119
+
120
+ INLINE_MATCHES=$(grep -rn --include="*.svelte" -E "$INLINE_PATTERN" src/ 2>/dev/null || true)
121
+
122
+ if [ -n "$INLINE_MATCHES" ]; then
123
+ echo "$INLINE_MATCHES" | while IFS= read -r line; do
124
+ echo -e " ${YELLOW}$line${NC}"
125
+ done
126
+ INLINE_COUNT=$(echo "$INLINE_MATCHES" | wc -l | tr -d ' ')
127
+ ISSUES=$((ISSUES + INLINE_COUNT))
128
+ echo ""
129
+ echo " Found $INLINE_COUNT hardcoded inline colors → use semantic token classes"
130
+ else
131
+ echo " ✓ No hardcoded inline colors found"
132
+ fi
133
+
134
+ echo ""
135
+
136
+ # ─────────────────────────────────────────────────────────
137
+ # 4. Class string concatenation (should use cn())
138
+ # ─────────────────────────────────────────────────────────
139
+
140
+ echo -e "${CYAN}── Class Concatenation ──${NC}"
141
+ echo ""
142
+
143
+ # Look for class={`...`} or class={something + "..."} patterns
144
+ CONCAT_PATTERN='class=\{`|class=\{[^}]*\+'
145
+
146
+ CONCAT_MATCHES=$(grep -rn --include="*.svelte" -E "$CONCAT_PATTERN" src/ 2>/dev/null | grep -v 'cn(' || true)
147
+
148
+ if [ -n "$CONCAT_MATCHES" ]; then
149
+ echo "$CONCAT_MATCHES" | while IFS= read -r line; do
150
+ echo -e " ${YELLOW}$line${NC}"
151
+ done
152
+ CONCAT_COUNT=$(echo "$CONCAT_MATCHES" | wc -l | tr -d ' ')
153
+ ISSUES=$((ISSUES + CONCAT_COUNT))
154
+ echo ""
155
+ echo " Found $CONCAT_COUNT class concatenations → use cn() from \$lib/utils.js"
156
+ else
157
+ echo " ✓ No class string concatenation found"
158
+ fi
159
+
160
+ echo ""
161
+
162
+ # ─────────────────────────────────────────────────────────
163
+ # Summary
164
+ # ─────────────────────────────────────────────────────────
165
+
166
+ echo "═══════════════════════════════════════════════════"
167
+ echo " Audit Complete"
168
+ echo "═══════════════════════════════════════════════════"
169
+ echo ""