@archetypeai/ds-cli 0.3.9 → 0.3.11

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.
Files changed (29) hide show
  1. package/bin.js +4 -0
  2. package/commands/create.js +76 -33
  3. package/commands/init.js +49 -19
  4. package/files/AGENTS.md +19 -3
  5. package/files/CLAUDE.md +21 -3
  6. package/files/rules/accessibility.md +49 -0
  7. package/files/rules/frontend-architecture.md +77 -0
  8. package/files/skills/apply-ds/SKILL.md +86 -82
  9. package/files/skills/apply-ds/scripts/audit.sh +169 -0
  10. package/files/skills/apply-ds/scripts/setup.sh +48 -166
  11. package/files/skills/create-dashboard/SKILL.md +12 -0
  12. package/files/skills/embedding-from-file/SKILL.md +415 -0
  13. package/files/skills/embedding-from-sensor/SKILL.md +406 -0
  14. package/files/skills/embedding-upload/SKILL.md +414 -0
  15. package/files/skills/fix-accessibility/SKILL.md +57 -9
  16. package/files/skills/newton-activity-monitor-lens-on-video/SKILL.md +817 -0
  17. package/files/skills/newton-camera-frame-analysis/SKILL.md +611 -0
  18. package/files/skills/newton-camera-frame-analysis/scripts/activity-monitor-frame.py +165 -0
  19. package/files/skills/newton-camera-frame-analysis/scripts/captures/logs/api_responses_20260206_105610.json +62 -0
  20. package/files/skills/newton-camera-frame-analysis/scripts/continuous_monitor.py +119 -0
  21. package/files/skills/newton-direct-query/SKILL.md +212 -0
  22. package/files/skills/newton-direct-query/scripts/direct_query.py +129 -0
  23. package/files/skills/newton-machine-state-from-file/SKILL.md +545 -0
  24. package/files/skills/newton-machine-state-from-sensor/SKILL.md +707 -0
  25. package/files/skills/newton-machine-state-upload/SKILL.md +986 -0
  26. package/lib/add-ds-config-codeagent.js +5 -1
  27. package/lib/is-interactive.js +19 -0
  28. package/lib/scaffold-ds-svelte-project.js +117 -0
  29. package/package.json +1 -1
@@ -1,117 +1,121 @@
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:
26
-
27
- - A global CSS file at `src/app.css`, `src/routes/layout.css`, or `src/app.pcss`
28
-
29
- ## Manual Setup
30
-
31
- ### Step 1: Install Tokens
32
-
33
- ```bash
34
- npm i @archetypeai/ds-lib-tokens
35
- ```
36
-
37
- ### Step 2: Install and Configure Tailwind CSS
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:
38
23
 
39
- Install Tailwind CSS v4 and its Vite plugin:
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()`
40
28
 
41
- ```bash
42
- npm i -D tailwindcss @tailwindcss/vite
43
- ```
29
+ Review the output to prioritize what to migrate.
44
30
 
45
- Then add the `@tailwindcss/vite` plugin to your `vite.config.js`:
31
+ ## Step 2: Replace Raw Colors with Semantic Tokens
46
32
 
47
- ```js
48
- import tailwindcss from '@tailwindcss/vite';
33
+ Replace raw Tailwind color utilities with semantic equivalents throughout `.svelte` files:
49
34
 
50
- export default defineConfig({
51
- plugins: [svelte(), tailwindcss()]
52
- // ...
53
- });
54
- ```
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` |
55
55
 
56
- The setup script handles this automatically it detects your vite config file, adds the import, and inserts `tailwindcss()` into the plugins array.
56
+ Use judgementnot every raw color maps 1:1. Context matters:
57
57
 
58
- ### Step 3: Initialize shadcn-svelte
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`
59
62
 
60
- The `--css` flag should point to your project's global CSS file:
63
+ Leave non-color utilities (`p-4`, `flex`, `rounded-lg`, etc.) unchanged.
61
64
 
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
- ```
65
+ ## Step 3: Replace Native Elements with DS Components
74
66
 
75
- ### Step 4: Install Components
67
+ Swap native HTML elements for their DS component equivalents. Add imports as needed.
76
68
 
77
- Install all components:
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` |
78
80
 
79
- ```bash
80
- npx @archetypeai/ds-cli add ds-ui-svelte
81
- ```
81
+ For each replacement:
82
82
 
83
- Or install individually:
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">`
84
87
 
85
- ```bash
86
- npx shadcn-svelte@latest add https://design-system.archetypeai.workers.dev/r/button.json
87
- ```
88
+ ## Step 4: Apply Layout Patterns
88
89
 
89
- ### Step 5: Configure CSS Imports
90
+ Identify structural opportunities to use DS composition patterns:
90
91
 
91
- Replace the contents of your global CSS file with:
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>`
92
98
 
93
- ```css
94
- @import '@archetypeai/ds-lib-tokens/theme.css';
95
- @import 'tailwindcss';
96
- ```
99
+ Import patterns from `$lib/components/ui/` as needed.
97
100
 
98
- ### Step 6: Set Up Linting
101
+ ## Step 5: Lint and Format
99
102
 
100
- Install dependencies:
103
+ Run linting and formatting to clean up the migrated code:
101
104
 
102
105
  ```bash
103
- npm i -D eslint prettier eslint-plugin-svelte eslint-config-prettier prettier-plugin-svelte prettier-plugin-tailwindcss globals
106
+ npm run lint:fix && npm run format
104
107
  ```
105
108
 
106
- The setup script creates `eslint.config.js`, `.prettierrc`, and `.prettierignore` automatically. See `@rules/linting.md` for details.
109
+ See `@rules/linting.md` for details.
107
110
 
108
- ## Verification
111
+ ## Step 6: Verify
109
112
 
110
- Confirm setup is complete:
113
+ Confirm the design system is properly applied:
111
114
 
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
115
+ - [ ] No raw Tailwind color utilities in `.svelte` files (re-run the audit script)
116
+ - [ ] Native elements replaced with DS components where appropriate
117
+ - [ ] All component imports resolve to `$lib/components/ui/`
118
+ - [ ] `cn()` used for class merging — no string concatenation
119
+ - [ ] Linting passes: `npm run lint && npm run format:check`
120
+ - [ ] App builds without errors: `npm run build`
121
+ - [ ] 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 ""
@@ -1,191 +1,56 @@
1
1
  #!/bin/bash
2
2
  #
3
- # Archetype AI Design System Setup Script
3
+ # Design System Linting & Formatting Setup
4
4
  #
5
- # Sets up a SvelteKit project with @archetypeai/ds-lib-tokens and design system components.
6
- # Fully non-interactive.
5
+ # Installs and configures ESLint + Prettier for a SvelteKit project
6
+ # using the Archetype AI design system.
7
7
  #
8
- # Usage: bash setup.sh
8
+ # Usage: bash <skill-dir>/scripts/setup.sh
9
9
  #
10
10
 
11
11
  set -e
12
12
 
13
13
  echo "═══════════════════════════════════════════════════"
14
- echo " Archetype AI Design System Setup"
14
+ echo " Linting & Formatting Setup"
15
15
  echo "═══════════════════════════════════════════════════"
16
16
  echo ""
17
17
 
18
- # ─────────────────────────────────────────────────────────
19
- # Prerequisites Check
20
- # ─────────────────────────────────────────────────────────
21
-
22
- if ! command -v node &> /dev/null; then
23
- echo "✗ Error: Node.js is not installed"
24
- echo " Install Node.js 18+ and try again"
25
- exit 1
26
- fi
27
-
28
- NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
29
- if [ "$NODE_VERSION" -lt 18 ]; then
30
- echo "✗ Error: Node.js 18+ required (found v$NODE_VERSION)"
31
- exit 1
32
- fi
33
-
34
18
  if [ ! -f "package.json" ]; then
35
19
  echo "✗ Error: No package.json found"
36
20
  echo " Run this script from your project root directory"
37
21
  exit 1
38
22
  fi
39
23
 
40
- # Detect global CSS file
41
- CSS_FILE=""
42
- if [ -f "src/app.css" ]; then
43
- CSS_FILE="src/app.css"
44
- elif [ -f "src/routes/layout.css" ]; then
45
- CSS_FILE="src/routes/layout.css"
46
- elif [ -f "src/app.pcss" ]; then
47
- CSS_FILE="src/app.pcss"
48
- fi
49
-
50
- if [ -z "$CSS_FILE" ]; then
51
- echo "✗ Error: No global CSS file found"
52
- echo " Checked: src/app.css, src/routes/layout.css, src/app.pcss"
53
- echo " Create a global CSS file and run again."
54
- exit 1
55
- fi
56
-
57
- echo "✓ Prerequisites OK (Node v$NODE_VERSION, CSS: $CSS_FILE)"
58
- echo ""
59
-
60
24
  # ─────────────────────────────────────────────────────────
61
- # Step 1: Install Tokens
25
+ # Install Dependencies
62
26
  # ─────────────────────────────────────────────────────────
63
27
 
64
- echo "Step 1/6: Installing @archetypeai/ds-lib-tokens..."
28
+ echo "Installing linting dependencies..."
65
29
 
66
- if grep -q '"@archetypeai/ds-lib-tokens"' package.json 2>/dev/null; then
67
- echo " Already installed, skipping"
68
- else
69
- npm i @archetypeai/ds-lib-tokens || {
70
- echo ""
71
- echo "✗ Installation failed."
72
- exit 1
73
- }
74
- echo " ✓ Tokens installed"
75
- fi
76
- echo ""
77
-
78
- # ─────────────────────────────────────────────────────────
79
- # Step 2: Install & Configure Tailwind CSS
80
- # ─────────────────────────────────────────────────────────
81
-
82
- echo "Step 2/6: Installing and configuring Tailwind CSS..."
83
-
84
- # Install tailwindcss + vite plugin if not present
85
- if grep -q '"tailwindcss"' package.json 2>/dev/null && grep -q '"@tailwindcss/vite"' package.json 2>/dev/null; then
86
- echo " → tailwindcss already installed, skipping"
87
- else
88
- npm i -D tailwindcss @tailwindcss/vite || {
89
- echo ""
90
- echo "✗ Failed to install tailwindcss"
91
- exit 1
92
- }
93
- echo " ✓ tailwindcss and @tailwindcss/vite installed"
94
- fi
95
-
96
- # Configure vite.config.js with @tailwindcss/vite plugin
97
- VITE_CONFIG=""
98
- if [ -f "vite.config.js" ]; then
99
- VITE_CONFIG="vite.config.js"
100
- elif [ -f "vite.config.ts" ]; then
101
- VITE_CONFIG="vite.config.ts"
102
- fi
103
-
104
- if [ -z "$VITE_CONFIG" ]; then
105
- echo " ⚠ No vite.config found — create one and add tailwindcss() to plugins manually"
106
- elif grep -q "@tailwindcss/vite" "$VITE_CONFIG" 2>/dev/null; then
107
- echo " → @tailwindcss/vite already configured in $VITE_CONFIG, skipping"
108
- else
109
- # Add import after the last import statement
110
- LAST_IMPORT_LINE=$(grep -n '^import ' "$VITE_CONFIG" | tail -1 | cut -d: -f1)
111
- if [ -n "$LAST_IMPORT_LINE" ]; then
112
- sed -i.bak "${LAST_IMPORT_LINE}a\\
113
- import tailwindcss from '@tailwindcss/vite';" "$VITE_CONFIG"
114
- else
115
- sed -i.bak "1i\\
116
- import tailwindcss from '@tailwindcss/vite';" "$VITE_CONFIG"
117
- fi
118
-
119
- # Add tailwindcss() to plugins array
120
- if grep -q 'plugins.*svelte()' "$VITE_CONFIG"; then
121
- sed -i.bak 's/svelte()/svelte(), tailwindcss()/' "$VITE_CONFIG"
122
- elif grep -q 'plugins.*\[' "$VITE_CONFIG"; then
123
- sed -i.bak 's/plugins:[[:space:]]*\[/plugins: [tailwindcss(), /' "$VITE_CONFIG"
124
- else
125
- echo " ⚠ Could not find plugins array — add tailwindcss() to plugins manually"
126
- fi
127
-
128
- rm -f "${VITE_CONFIG}.bak"
129
- echo " ✓ @tailwindcss/vite configured in $VITE_CONFIG"
130
- fi
30
+ npm i -D eslint prettier eslint-plugin-svelte eslint-config-prettier prettier-plugin-svelte prettier-plugin-tailwindcss globals 2>/dev/null || {
31
+ echo " Failed to install dependencies"
32
+ exit 1
33
+ }
34
+ echo " ✓ Dependencies installed"
131
35
  echo ""
132
36
 
133
37
  # ─────────────────────────────────────────────────────────
134
- # Step 3: Initialize shadcn-svelte
38
+ # Detect CSS file for Prettier Tailwind plugin
135
39
  # ─────────────────────────────────────────────────────────
136
40
 
137
- echo "Step 3/6: Initializing shadcn-svelte..."
138
-
139
- if [ -f "components.json" ]; then
140
- echo " → components.json exists, skipping init"
141
- else
142
- npx shadcn-svelte@latest init \
143
- --base-color slate \
144
- --css "$CSS_FILE" \
145
- --components-alias '$lib/components' \
146
- --lib-alias '$lib' \
147
- --utils-alias '$lib/utils' \
148
- --hooks-alias '$lib/hooks' \
149
- --ui-alias '$lib/components/ui' \
150
- --skip-preflight \
151
- --no-deps
152
- echo " ✓ shadcn-svelte initialized"
41
+ CSS_FILE=""
42
+ if [ -f "src/app.css" ]; then
43
+ CSS_FILE="src/app.css"
44
+ elif [ -f "src/routes/layout.css" ]; then
45
+ CSS_FILE="src/routes/layout.css"
46
+ elif [ -f "src/app.pcss" ]; then
47
+ CSS_FILE="src/app.pcss"
153
48
  fi
154
- echo ""
155
49
 
156
50
  # ─────────────────────────────────────────────────────────
157
- # Step 4: Install Components
51
+ # Create eslint.config.js
158
52
  # ─────────────────────────────────────────────────────────
159
53
 
160
- echo "Step 4/6: Installing design system components..."
161
- npx @archetypeai/ds-cli add ds-ui-svelte
162
- echo " ✓ Components installed"
163
- echo ""
164
-
165
- # ─────────────────────────────────────────────────────────
166
- # Step 5: Configure CSS Imports
167
- # ─────────────────────────────────────────────────────────
168
-
169
- echo "Step 5/6: Configuring CSS imports..."
170
-
171
- cat > "$CSS_FILE" << 'EOF'
172
- @import '@archetypeai/ds-lib-tokens/theme.css';
173
- @import 'tailwindcss';
174
- EOF
175
-
176
- echo " ✓ CSS imports written to $CSS_FILE"
177
- echo ""
178
-
179
- # ─────────────────────────────────────────────────────────
180
- # Step 6: Set Up Linting & Formatting
181
- # ─────────────────────────────────────────────────────────
182
-
183
- echo "Step 6/6: Setting up linting and formatting..."
184
-
185
- npm i -D eslint prettier eslint-plugin-svelte eslint-config-prettier prettier-plugin-svelte prettier-plugin-tailwindcss globals 2>/dev/null || true
186
- echo " ✓ Linting dependencies installed"
187
-
188
- # Create eslint.config.js if it doesn't exist
189
54
  if [ ! -f "eslint.config.js" ]; then
190
55
  cat > eslint.config.js << 'ESLINT_EOF'
191
56
  import js from '@eslint/js';
@@ -218,9 +83,13 @@ else
218
83
  echo " → eslint.config.js exists, skipping"
219
84
  fi
220
85
 
221
- # Create .prettierrc if it doesn't exist
86
+ # ─────────────────────────────────────────────────────────
87
+ # Create .prettierrc
88
+ # ─────────────────────────────────────────────────────────
89
+
222
90
  if [ ! -f ".prettierrc" ]; then
223
- cat > .prettierrc << PRETTIER_EOF
91
+ if [ -n "$CSS_FILE" ]; then
92
+ cat > .prettierrc << PRETTIER_EOF
224
93
  {
225
94
  "useTabs": true,
226
95
  "singleQuote": true,
@@ -230,12 +99,26 @@ if [ ! -f ".prettierrc" ]; then
230
99
  "tailwindStylesheet": "./$CSS_FILE"
231
100
  }
232
101
  PRETTIER_EOF
102
+ else
103
+ cat > .prettierrc << 'PRETTIER_EOF'
104
+ {
105
+ "useTabs": true,
106
+ "singleQuote": true,
107
+ "trailingComma": "none",
108
+ "printWidth": 100,
109
+ "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"]
110
+ }
111
+ PRETTIER_EOF
112
+ fi
233
113
  echo " ✓ .prettierrc created"
234
114
  else
235
115
  echo " → .prettierrc exists, skipping"
236
116
  fi
237
117
 
238
- # Create .prettierignore if it doesn't exist
118
+ # ─────────────────────────────────────────────────────────
119
+ # Create .prettierignore
120
+ # ─────────────────────────────────────────────────────────
121
+
239
122
  if [ ! -f ".prettierignore" ]; then
240
123
  cat > .prettierignore << 'IGNORE_EOF'
241
124
  .svelte-kit
@@ -251,21 +134,20 @@ else
251
134
  echo " → .prettierignore exists, skipping"
252
135
  fi
253
136
 
254
- # Add lint/format scripts to package.json
137
+ # ─────────────────────────────────────────────────────────
138
+ # Add scripts to package.json
139
+ # ─────────────────────────────────────────────────────────
140
+
255
141
  npm pkg set scripts.lint="eslint ." 2>/dev/null || true
256
142
  npm pkg set scripts.lint:fix="eslint . --fix" 2>/dev/null || true
257
143
  npm pkg set scripts.format="prettier --write ." 2>/dev/null || true
258
144
  npm pkg set scripts.format:check="prettier --check ." 2>/dev/null || true
259
145
  echo " ✓ Lint/format scripts added to package.json"
260
- echo ""
261
-
262
- # ─────────────────────────────────────────────────────────
263
- # Complete
264
- # ─────────────────────────────────────────────────────────
265
146
 
147
+ echo ""
266
148
  echo "═══════════════════════════════════════════════════"
267
149
  echo " Setup Complete"
268
150
  echo "═══════════════════════════════════════════════════"
269
151
  echo ""
270
- echo " Components are in \$lib/components/ui/"
152
+ echo " Run: npm run lint:fix && npm run format"
271
153
  echo ""