auto-backup: 2025-12-12 10:20:33 (21 files: +0 ~20 -0)

Generated by DSS Git Backup Hook
This commit is contained in:
2025-12-12 07:20:33 -03:00
parent 513ed3ef6c
commit b02ff696fc
21 changed files with 1334 additions and 1351 deletions

View File

@@ -1,5 +1,5 @@
# DSS Core Structure Hashes
# Generated: 2025-12-12T07:15:27-03:00
# Generated: 2025-12-12T07:20:15-03:00
# Source: Figma sync pipeline
# DO NOT EDIT MANUALLY
@@ -21,7 +21,7 @@ cd6289fed900da096b865bf91e940ff572df868391b31e25d222c055b9e56724 dss-claude-plu
f31e1c18143dd0eabac99f3a53aa5a4b3ed2b91743a035e7b7f4723fd4e25789 .dss/data/_system/components.json
891df6be8321f7dc00766fc6b95f5a9821f34e08f7e70e54d2e6dc8edab86351 .dss/data/_system/styles.json
4321119e41b6763a49d654978161b02dead66116ecca6c7f215e021cacfeeab1 .dss/data/_system/ds.config.json
d7bb269b049bcbb9b74b90f29c398a0e6cc24ea015d6b2a0468d8166dd1d1a49 .dss/data/_system/tokens/figma-tokens.json
3242ccb81ca30197e78251453f4594c271afe02502204900329f03ee92a9b7a3 .dss/data/_system/tokens/base.json
9d7c8dc343cc3cd3a123a10b4a74427174a7b662e756b98a468aa2aa39062690 .dss/data/_system/tokens/resolved-meta.json
e699ae31cb92097aa8cc125c251435d021b3764baa05947aaa1af8b11f5d20d4 .dss/data/_system/tokens/figma-tokens.json
44a2427219935b46dc954b35964344fd682300dc434dfa63d4764702521dd6ae .dss/data/_system/tokens/base.json
11ff8e346b987fc26e5c1992e6f107692aa25bd70edb041eb47ef23a6cb734f9 .dss/data/_system/tokens/resolved-meta.json
9175c3bf0581b652d10704a2d85f1ec9fc68809e90850c01d9acd1d571618a6a .dss/data/_system/tokens/tokens.json

View File

@@ -1,9 +1,4 @@
{
"_meta": {
"version": "1.0.0",
"generated": null,
"source": "awaiting Figma sync",
"status": "empty"
},
"_meta": {"version": "1.0.0", "status": "empty"},
"tokens": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
{
"resolved_at": "2025-12-12T07:15:27.540357",
"resolved_at": "2025-12-12T07:20:15.035073",
"skin": "shadcn",
"theme": "default",
"token_count": 68,

View File

@@ -1,7 +1,7 @@
/**
* Color Primitives - Foundation
* Full Tailwind color palette organized by category
* @generated 2025-12-12T07:15:27.637506
* @generated 2025-12-12T07:20:15.120305
*/
export default {
title: 'Foundation/Colors/Primitives',

View File

@@ -1,7 +1,7 @@
/**
* Data Display
* Components for displaying data
* @generated 2025-12-12T07:15:27.638482
* @generated 2025-12-12T07:20:15.121308
*/
export default {
title: 'Components/Data Display',

View File

@@ -1,7 +1,7 @@
/**
* Feedback
* User feedback components
* @generated 2025-12-12T07:15:27.638601
* @generated 2025-12-12T07:20:15.121440
*/
export default {
title: 'Components/Feedback',

View File

@@ -1,7 +1,7 @@
/**
* Form Components
* Input controls and form elements
* @generated 2025-12-12T07:15:27.638330
* @generated 2025-12-12T07:20:15.121157
*/
export default {
title: 'Components/Form Components',

View File

@@ -1,7 +1,7 @@
/**
* Layout
* Layout and structure components
* @generated 2025-12-12T07:15:27.638937
* @generated 2025-12-12T07:20:15.121772
*/
export default {
title: 'Components/Layout',

View File

@@ -1,7 +1,7 @@
/**
* Navigation
* Navigation components
* @generated 2025-12-12T07:15:27.638701
* @generated 2025-12-12T07:20:15.121540
*/
export default {
title: 'Components/Navigation',

View File

@@ -1,7 +1,7 @@
/**
* Overlay
* Modal and overlay components
* @generated 2025-12-12T07:15:27.638818
* @generated 2025-12-12T07:20:15.121650
*/
export default {
title: 'Components/Overlay',

View File

@@ -1,6 +1,6 @@
/**
* Design System Overview
* @generated 2025-12-12T07:15:27.637235
* @generated 2025-12-12T07:20:15.120041
*/
export default {
title: 'Overview',

View File

@@ -1,6 +1,6 @@
/**
* Border Radius - Foundation
* @generated 2025-12-12T07:15:27.637975
* @generated 2025-12-12T07:20:15.120771
*/
export default {
title: 'Foundation/Radius',

View File

@@ -1,7 +1,7 @@
/**
* Semantic Colors - Design Tokens
* Resolved color tokens for light theme
* @generated 2025-12-12T07:15:27.638208
* @generated 2025-12-12T07:20:15.121023
*/
export default {
title: 'Tokens/Semantic Colors',

View File

@@ -1,7 +1,7 @@
/**
* Shadows - Foundation
* Box shadow scale
* @generated 2025-12-12T07:15:27.638085
* @generated 2025-12-12T07:20:15.120889
*/
export default {
title: 'Foundation/Effects/Shadows',

View File

@@ -1,6 +1,6 @@
/**
* Spacing Primitives - Foundation
* @generated 2025-12-12T07:15:27.637656
* @generated 2025-12-12T07:20:15.120448
*/
export default {
title: 'Foundation/Spacing',

View File

@@ -1,7 +1,7 @@
/**
* Typography - Foundation
* Font families, sizes, weights, and composed styles
* @generated 2025-12-12T07:15:27.637826
* @generated 2025-12-12T07:20:15.120621
*/
export default {
title: 'Foundation/Typography',

View File

@@ -1,49 +1,39 @@
---
name: dss-init
description: Full DSS workflow - reset, structure, analyze, sync, build CSS
description: Complete DSS setup - MCP, dependencies, Figma sync, CSS build, servers
arguments:
- name: flags
description: Optional flags (--reset, --skip-analysis)
description: Optional flags (--reset, --skip-analysis, --skip-servers, --servers-only)
required: false
---
# DSS Init Command - Full Workflow Pipeline
# DSS Init Command - Complete Setup & Build Pipeline
Complete DSS initialization and build pipeline for admin-ui and storybook targets.
Single entry point for all DSS initialization. Handles MCP config, dependencies, Figma sync, CSS generation, and dev servers.
## Usage
```
/dss-init [--reset] [--skip-analysis]
/dss-init [--reset] [--skip-analysis] [--skip-servers] [--servers-only]
```
## Full Workflow
## Full Workflow (15 steps)
1. **Reset** (with --reset flag)
- Clears all DSS data, tokens, themes
- Resets skins to empty state
- Removes generated CSS/stories
2. **Validate Environment**
- Python3, Node.js, style-dictionary
- FIGMA_TOKEN availability
3. **Create Structure**
- `.dss/data/_system/themes/` - CSS output
- `.dss/data/_system/tokens/` - Token JSON
- Database initialization
4. **Analyze Targets**
- admin-ui: web app consumer
- storybook: documentation
5. **Figma Sync** (MCP required)
- Uses `dss_sync_figma` tool
- Populates tokens from Figma
6. **Build CSS**
- Runs style-dictionary
- Generates tokens.css, _tokens.scss, tokens.json
1. **Reset** (with --reset) - Clear all DSS data
2. **MCP Config** - Generate `.mcp.json`
3. **Dependencies** - Python venv, Node modules, admin-ui build
4. **Environment** - Validate Python, Node, Figma token
5. **Directory Structure** - Create `.dss/` folders
6. **Database** - Initialize SQLite
7. **Analyze Targets** - admin-ui, storybook stats
8. **Token Structure** - Create base token files
9. **3-Layer Validation** - Core, skins, themes
10. **Figma Sync** - Fetch tokens from Figma
11. **Token Cascade** - Resolve Core → Skin → Theme
12. **Build CSS** - Run style-dictionary
13. **Storybook Stories** - Generate from tokens
14. **Hash Manifest** - Update checksums
15. **Start Servers** - admin-ui + Storybook
## Instructions for Claude
@@ -51,34 +41,49 @@ When the user runs this command:
1. Execute: `scripts/dss-init.sh [flags]`
2. If status shows "AWAITING FIGMA SYNC":
- Run `dss_sync_figma` MCP tool to populate tokens
- Re-run `scripts/dss-init.sh` to build CSS
3. If status shows "READY":
- admin-ui can import from `.dss/data/_system/themes/`
2. After completion:
- If first time, remind user to restart Claude Code to load MCP
- If status shows "AWAITING FIGMA SYNC", ensure FIGMA_TOKEN is configured
## Flags
- `--reset`: Clear everything first (fresh start)
- `--skip-analysis`: Skip code analysis step
| Flag | Description |
|------|-------------|
| `--reset` | Clear everything first (fresh start) |
| `--skip-analysis` | Skip target project analysis |
| `--skip-servers` | Don't start development servers |
| `--servers-only` | Only start servers (skip all init steps) |
## Typical Workflow
## Services
| Service | Port | URL |
|---------|------|-----|
| admin-ui | 3456 | http://localhost:3456 |
| Storybook | 6006 | http://localhost:6006 |
## Common Workflows
```bash
# Fresh start
scripts/dss-init.sh --reset
# Fresh start (reset + full init + servers)
/dss-init --reset
# Populate tokens (MCP tool)
dss_sync_figma
# Incremental update (no reset, keeps data)
/dss-init
# Build CSS
scripts/dss-init.sh
# CI/CD mode (no servers)
/dss-init --skip-servers
# admin-ui imports from .dss/data/_system/themes/
# Just start servers
/dss-init --servers-only
```
## Logs
- `/tmp/dss-admin-ui.log`
- `/tmp/dss-storybook.log`
## Related Commands
- `/dss-figma` - Sync tokens from Figma
- `/dss-reset` - Reset to clean state only (no init)
- `/dss-figma` - Sync tokens from Figma only
- `/dss-analyze` - Analyze specific project

View File

@@ -1,70 +1,38 @@
---
name: dss-setup
description: Complete DSS setup - MCP config, init, and start servers
description: DEPRECATED - Use /dss-init instead
arguments:
- name: flags
description: Optional flags (--reset, --skip-servers)
required: false
---
# DSS Setup Command
# DSS Setup Command (DEPRECATED)
Complete DSS environment setup including MCP configuration, initialization, and development servers.
**This command is deprecated. Use `/dss-init` instead.**
## Usage
The `/dss-init` command now handles everything that `/dss-setup` did:
- MCP configuration
- Dependencies (Python venv, Node modules)
- DSS initialization
- Development servers
```
/dss-setup [--reset] [--skip-servers]
```
## Migration
## What This Does
1. **Generate MCP Config**
- Creates `.mcp.json` with absolute paths
- Configures DSS MCP server connection
2. **Check Dependencies**
- Python venv setup
- Node modules installation
3. **Initialize DSS** (calls dss-init.sh)
- Directory structure
- Database initialization
- Target analysis (admin-ui, storybook)
- Token structure
- Hash manifest
4. **Start Servers**
- admin-ui on port 3456
- Storybook on port 6006
| Old Command | New Command |
|-------------|-------------|
| `/dss-setup` | `/dss-init` |
| `/dss-setup --reset` | `/dss-init --reset` |
| `/dss-setup --skip-servers` | `/dss-init --skip-servers` |
## Instructions for Claude
When the user runs this command:
1. Execute: `scripts/dss-setup.sh [flags]`
1. Inform them that `/dss-setup` is deprecated
2. Run `/dss-init` with the same flags instead
2. After completion, remind user to restart Claude Code to load MCP server
## Flags
- `--reset`: Clear all DSS data first (fresh start)
- `--skip-servers`: Don't start development servers
## Services
| Service | Port | URL |
|---------|------|-----|
| admin-ui | 3456 | http://localhost:3456 |
| Storybook | 6006 | http://localhost:6006 |
## Logs
- `/tmp/dss-admin-ui.log`
- `/tmp/dss-storybook.log`
## Related Commands
- `/dss-init` - Initialize DSS structure only
- `/dss-reset` - Reset to clean state
- `/dss-figma` - Sync tokens from Figma
```bash
# Just run dss-init.sh directly
scripts/dss-init.sh [flags]
```

View File

@@ -1,36 +1,39 @@
#!/bin/bash
# DSS Initialization Script - Full Workflow
# Sets up complete DSS structure and manages the entire pipeline
# DSS Initialization Script - Complete Setup & Build Pipeline
#
# Usage: scripts/dss-init.sh [--reset] [--skip-analysis]
# This is the single entry point for DSS setup. It handles:
# - MCP configuration
# - Dependencies (Python venv, Node modules)
# - Directory structure and database
# - Figma sync and token resolution
# - CSS generation with style-dictionary
# - Storybook story generation
# - Development servers (optional)
#
# Full Workflow:
# 1. Reset to clean state (optional, with --reset)
# 2. Create directory structure and database
# 3. Analyze target projects (admin-ui, storybook)
# 4. Figma sync (requires FIGMA_TOKEN, uses MCP)
# 5. Build CSS with style-dictionary
# 6. admin-ui imports from .dss/data/_system/themes/
# Usage: scripts/dss-init.sh [--reset] [--skip-analysis] [--skip-servers]
#
# Flags:
# --reset Clear all DSS data first (fresh start)
# --skip-analysis Skip target project analysis
# --skip-servers Don't start development servers
# --servers-only Only start servers (skip init steps)
set -e
DSS_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$DSS_ROOT"
# Use venv Python if available
if [ -f "$DSS_ROOT/.venv/bin/python3" ]; then
PYTHON="$DSS_ROOT/.venv/bin/python3"
else
PYTHON="python3"
fi
# Parse arguments
RESET=false
SKIP_ANALYSIS=false
SKIP_SERVERS=false
SERVERS_ONLY=false
for arg in "$@"; do
case $arg in
--reset) RESET=true ;;
--skip-analysis) SKIP_ANALYSIS=true ;;
--skip-servers) SKIP_SERVERS=true ;;
--servers-only) SERVERS_ONLY=true ;;
esac
done
@@ -50,10 +53,46 @@ log_info() { echo -e "${CYAN}[INFO]${NC} $1"; }
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ DSS INITIALIZATION ║"
echo "║ Full Workflow Pipeline ║"
echo "║ Complete Setup & Build Pipeline ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
# ============================================================================
# SERVERS ONLY MODE
# ============================================================================
if [ "$SERVERS_ONLY" = true ]; then
log_step "Starting development servers only..."
# Kill existing processes
pkill -f "vite.*admin-ui" 2>/dev/null || true
pkill -f "storybook.*6006" 2>/dev/null || true
sleep 1
cd "$DSS_ROOT/admin-ui"
nohup npm run dev > /tmp/dss-admin-ui.log 2>&1 &
log_info "admin-ui starting (PID: $!)..."
nohup npm run storybook > /tmp/dss-storybook.log 2>&1 &
log_info "Storybook starting (PID: $!)..."
cd "$DSS_ROOT"
sleep 5
if curl -s -o /dev/null -w "" http://localhost:3456 2>/dev/null; then
log_ok "admin-ui: http://localhost:3456"
else
log_warn "admin-ui not responding yet (check /tmp/dss-admin-ui.log)"
fi
if curl -s -o /dev/null -w "" http://localhost:6006 2>/dev/null; then
log_ok "Storybook: http://localhost:6006"
else
log_warn "Storybook not responding yet (check /tmp/dss-storybook.log)"
fi
exit 0
fi
# ============================================================================
# STEP 1: Reset (if requested)
# ============================================================================
@@ -85,9 +124,8 @@ if [ "$RESET" = true ]; then
}
EOF
# Reset skins
# Reset skins (macOS bash 3 compatible)
for skin in base classic workbench; do
# Capitalize first letter (macOS bash 3 compatible)
skin_cap="$(echo "$skin" | sed 's/./\U&/')"
if [ "$skin" = "base" ]; then
cat > "dss-claude-plugin/core/skins/${skin}.json" << EOF
@@ -127,42 +165,101 @@ else
fi
# ============================================================================
# STEP 2: Validate Environment
# STEP 2: Generate MCP Configuration
# ============================================================================
log_step "2. Validating DSS environment..."
log_step "2. Generating MCP configuration..."
cat > "$DSS_ROOT/.mcp.json" << EOF
{
"\$schema": "https://raw.githubusercontent.com/anthropics/claude-code/main/schemas/mcp-servers.schema.json",
"mcpServers": {
"dss": {
"command": "$DSS_ROOT/.venv/bin/python3",
"args": ["$DSS_ROOT/dss-claude-plugin/servers/dss-mcp-server.py"],
"env": {
"PYTHONPATH": "$DSS_ROOT:$DSS_ROOT/dss-claude-plugin",
"DSS_HOME": "$DSS_ROOT/.dss",
"DSS_DATABASE": "$DSS_ROOT/.dss/dss.db",
"DSS_CACHE": "$DSS_ROOT/.dss/cache",
"DSS_BASE_PATH": "$DSS_ROOT"
},
"description": "Design System Server MCP - local development"
}
}
}
EOF
log_ok "MCP config: .mcp.json"
echo ""
# ============================================================================
# STEP 3: Check/Install Dependencies
# ============================================================================
log_step "3. Checking dependencies..."
# Check/create Python venv
if [ ! -d "$DSS_ROOT/.venv" ]; then
log_info "Creating Python virtual environment..."
python3 -m venv "$DSS_ROOT/.venv"
fi
# Use venv Python
PYTHON="$DSS_ROOT/.venv/bin/python3"
# Activate venv and check packages
source "$DSS_ROOT/.venv/bin/activate"
if ! python3 -c "import mcp" 2>/dev/null; then
log_info "Installing MCP package..."
pip install mcp 2>/dev/null || log_warn "MCP package install failed"
fi
log_ok "Python venv ready"
# Check admin-ui node_modules
if [ ! -d "$DSS_ROOT/admin-ui/node_modules" ]; then
log_info "Installing admin-ui dependencies..."
cd "$DSS_ROOT/admin-ui" && npm install --legacy-peer-deps
cd "$DSS_ROOT"
fi
log_ok "Node dependencies ready"
# Build admin-ui
log_info "Building admin-ui..."
cd "$DSS_ROOT/admin-ui"
npm run build 2>&1 | tail -5
cd "$DSS_ROOT"
log_ok "admin-ui built (dist/)"
# Check style-dictionary
STYLE_DICT_AVAILABLE=false
FIGMA_AVAILABLE=false
# Check Python
if ! command -v python3 &> /dev/null; then
log_error "Python3 not found"
exit 1
fi
log_ok "Python3: $(python3 --version | cut -d' ' -f2)"
# Check Node.js
if command -v node &> /dev/null; then
log_ok "Node.js: $(node --version)"
else
log_warn "Node.js not found - Storybook features limited"
fi
# Check style-dictionary (project, home, or global)
if command -v style-dictionary &> /dev/null; then
STYLE_DICT_CMD=""
if [ -f "$DSS_ROOT/node_modules/.bin/style-dictionary" ]; then
STYLE_DICT_AVAILABLE=true
log_ok "style-dictionary: available"
elif [ -f "node_modules/.bin/style-dictionary" ]; then
STYLE_DICT_AVAILABLE=true
log_ok "style-dictionary: local install"
STYLE_DICT_CMD="$DSS_ROOT/node_modules/.bin/style-dictionary"
log_ok "style-dictionary: local"
elif [ -f "$HOME/node_modules/.bin/style-dictionary" ]; then
STYLE_DICT_AVAILABLE=true
log_ok "style-dictionary: installed (~)"
STYLE_DICT_CMD="$HOME/node_modules/.bin/style-dictionary"
log_ok "style-dictionary: global (~)"
elif command -v style-dictionary &> /dev/null; then
STYLE_DICT_AVAILABLE=true
STYLE_DICT_CMD="style-dictionary"
log_ok "style-dictionary: global"
else
log_warn "style-dictionary not installed (npm install -g style-dictionary)"
log_warn "style-dictionary not installed (npm install style-dictionary)"
fi
# Check Figma token - load from config if not in environment
echo ""
# ============================================================================
# STEP 4: Validate Environment
# ============================================================================
log_step "4. Validating environment..."
log_ok "Python: $(python3 --version | cut -d' ' -f2)"
log_ok "Node.js: $(node --version)"
# Check Figma token
FIGMA_AVAILABLE=false
FIGMA_CONFIG=".dss/config/figma.json"
if [ -z "$FIGMA_TOKEN" ] && [ -f "$FIGMA_CONFIG" ]; then
FIGMA_TOKEN=$(python3 -c "import json; print(json.load(open('$FIGMA_CONFIG')).get('token',''))" 2>/dev/null)
@@ -171,22 +268,21 @@ fi
if [ -n "$FIGMA_TOKEN" ]; then
FIGMA_AVAILABLE=true
log_ok "FIGMA_TOKEN: configured (from .dss/config/figma.json)"
# Also show UIKit reference if available
log_ok "FIGMA_TOKEN: configured"
if [ -f "$FIGMA_CONFIG" ]; then
UIKIT_NAME=$(python3 -c "import json; d=json.load(open('$FIGMA_CONFIG')); print(d.get('uikit_reference',{}).get('name',''))" 2>/dev/null)
[ -n "$UIKIT_NAME" ] && log_ok "UIKit reference: $UIKIT_NAME"
[ -n "$UIKIT_NAME" ] && log_ok "UIKit: $UIKIT_NAME"
fi
else
log_warn "FIGMA_TOKEN not set - add to .dss/config/figma.json"
log_warn "FIGMA_TOKEN not set"
fi
echo ""
# ============================================================================
# STEP 3: Create Directory Structure
# STEP 5: Create Directory Structure
# ============================================================================
log_step "3. Creating DSS directory structure..."
log_step "5. Creating directory structure..."
mkdir -p .dss/data/{_system/{tokens,themes,components,cache,activity},projects,teams}
mkdir -p .dss/schema
@@ -194,33 +290,22 @@ mkdir -p .dss/logs/browser-logs
touch .dss/logs/dss-operations.jsonl
touch .dss/logs/git-hooks.jsonl
# Create _system ds.config.json
# Create ds.config.json
if [ ! -f ".dss/data/_system/ds.config.json" ]; then
cat > .dss/data/_system/ds.config.json << 'EOF'
{
"name": "dss-system",
"version": "1.0.0",
"description": "DSS internal design system (dogfooding)",
"description": "DSS internal design system",
"skin": "base",
"base_theme": "light",
"targets": [
{
"name": "admin-ui",
"path": "./admin-ui",
"type": "web-app",
"framework": "vanilla"
},
{
"name": "storybook",
"path": "./storybook",
"type": "documentation",
"framework": "storybook"
}
{"name": "admin-ui", "path": "./admin-ui", "type": "web-app"},
{"name": "storybook", "path": "./storybook", "type": "documentation"}
],
"output": {
"tokens_dir": "./.dss/data/_system/tokens",
"themes_dir": "./.dss/data/_system/themes",
"components_dir": "./.dss/data/_system/components",
"formats": ["css", "scss", "json"]
}
}
@@ -231,9 +316,9 @@ log_ok "Directory structure ready"
echo ""
# ============================================================================
# STEP 4: Initialize Database
# STEP 6: Initialize Database
# ============================================================================
log_step "4. Initializing database..."
log_step "6. Initializing database..."
if [ ! -f ".dss/dss.db" ]; then
python3 << 'PYEOF'
@@ -265,70 +350,45 @@ fi
echo ""
# ============================================================================
# STEP 5: Analyze Target Projects
# STEP 7: Analyze Target Projects
# ============================================================================
if [ "$SKIP_ANALYSIS" = false ]; then
log_step "5. Analyzing target projects..."
log_step "7. Analyzing targets..."
# Analyze admin-ui
if [ -d "admin-ui" ]; then
JS_COUNT=$(find admin-ui -name "*.js" -not -path "*/node_modules/*" 2>/dev/null | wc -l)
CSS_COUNT=$(find admin-ui -name "*.css" -not -path "*/node_modules/*" 2>/dev/null | wc -l)
HTML_COUNT=$(find admin-ui -name "*.html" -not -path "*/node_modules/*" 2>/dev/null | wc -l)
cat > .dss/data/_system/analysis-admin-ui.json << EOF
{"target":"admin-ui","analyzed_at":"$(date -Iseconds)","stats":{"js":$JS_COUNT,"css":$CSS_COUNT,"html":$HTML_COUNT},"status":"analyzed"}
EOF
log_ok "admin-ui: $JS_COUNT js, $CSS_COUNT css, $HTML_COUNT html"
else
log_warn "admin-ui directory not found"
log_ok "admin-ui: $JS_COUNT js, $CSS_COUNT css"
fi
# Analyze storybook
STORIES_COUNT=$(find . -name "*.stories.js" -o -name "*.stories.ts" 2>/dev/null | grep -v node_modules | wc -l)
MDX_COUNT=$(find . -name "*.mdx" 2>/dev/null | grep -v node_modules | wc -l)
cat > .dss/data/_system/analysis-storybook.json << EOF
{"target":"storybook","analyzed_at":"$(date -Iseconds)","stats":{"stories":$STORIES_COUNT,"mdx":$MDX_COUNT},"status":"analyzed"}
EOF
log_ok "storybook: $STORIES_COUNT stories, $MDX_COUNT mdx"
log_ok "storybook: $STORIES_COUNT stories"
echo ""
else
log_step "5. Skipping analysis (--skip-analysis)"
log_step "7. Skipping analysis (--skip-analysis)"
echo ""
fi
# ============================================================================
# STEP 6: Initialize Token Structure
# STEP 8: Initialize Token Structure
# ============================================================================
log_step "6. Checking token structure..."
log_step "8. Checking tokens..."
mkdir -p .dss/data/_system/tokens
if [ ! -f ".dss/data/_system/tokens/base.json" ]; then
cat > .dss/data/_system/tokens/base.json << 'EOF'
{
"_meta": {
"version": "1.0.0",
"generated": null,
"source": "awaiting Figma sync",
"status": "empty"
},
"_meta": {"version": "1.0.0", "status": "empty"},
"tokens": {}
}
EOF
log_ok "Empty token structure created"
log_ok "Token structure created"
else
# Check if tokens have content
TOKEN_STATUS=$(python3 -c "import json; d=json.load(open('.dss/data/_system/tokens/base.json')); print(d.get('_meta',{}).get('status','unknown'))" 2>/dev/null || echo "unknown")
if [ "$TOKEN_STATUS" = "empty" ]; then
log_warn "Tokens empty - run Figma sync to populate"
else
log_ok "Tokens present (status: $TOKEN_STATUS)"
fi
log_ok "Token structure exists"
fi
# Create style-dictionary config (paths relative to .dss/data/_system/ where it runs)
# Create style-dictionary config
cat > .dss/data/_system/style-dictionary.config.json << 'EOF'
{
"source": ["tokens/tokens.json"],
@@ -355,236 +415,194 @@ EOF
echo ""
# ============================================================================
# STEP 7: Validate 3-Layer Architecture
# STEP 9: Validate 3-Layer Architecture
# ============================================================================
log_step "7. Validating 3-layer architecture..."
log_step "9. Validating 3-layer architecture..."
# Check core primitives
if [ -f ".dss/core/primitives.json" ]; then
PRIM_COUNT=$(python3 -c "import json; d=json.load(open('.dss/core/primitives.json')); print(sum(len(v) if isinstance(v,dict) else 0 for k,v in d.items() if not k.startswith('_')))" 2>/dev/null || echo "0")
log_ok "Core primitives: $PRIM_COUNT tokens"
else
log_warn "Core primitives not found (.dss/core/primitives.json)"
log_ok "Core primitives: $PRIM_COUNT"
fi
# Check skin contract
if [ -f ".dss/schema/skin-contract.json" ]; then
log_ok "Skin contract defined"
else
log_warn "Skin contract not found (.dss/schema/skin-contract.json)"
fi
# Check skins
SKIN_COUNT=$(find .dss/skins -name "tokens.json" 2>/dev/null | wc -l)
if [ "$SKIN_COUNT" -gt 0 ]; then
log_ok "Skins available: $SKIN_COUNT"
for skin in $(find .dss/skins -type d -mindepth 1 -maxdepth 1 2>/dev/null); do
SKIN_NAME=$(basename "$skin")
log_info " - $SKIN_NAME"
done
else
log_warn "No skins found (.dss/skins/)"
fi
[ "$SKIN_COUNT" -gt 0 ] && log_ok "Skins: $SKIN_COUNT"
# Check themes
THEME_COUNT=$(find .dss/themes -name "*.json" 2>/dev/null | grep -v "_" | wc -l)
if [ "$THEME_COUNT" -gt 0 ]; then
log_ok "Themes available: $THEME_COUNT"
for theme in $(find .dss/themes -name "*.json" 2>/dev/null | grep -v "_"); do
THEME_NAME=$(basename "$theme" .json)
log_info " - $THEME_NAME"
done
else
log_warn "No themes found (.dss/themes/)"
fi
[ "$THEME_COUNT" -gt 0 ] && log_ok "Themes: $THEME_COUNT"
# Run validation if available
if [ -f "scripts/validate-theme.py" ] && [ -f ".dss/schema/skin-contract.json" ]; then
log_info "Running theme/skin validation..."
# Run validation
if [ -f "scripts/validate-theme.py" ]; then
log_info "Running validation..."
if $PYTHON scripts/validate-theme.py --validate-skin --quiet 2>&1 | while read line; do
echo " $line"
done; then
log_ok "All validations passed"
else
log_warn "Validation had issues - check output above"
log_ok "Validation passed"
fi
fi
echo ""
# ============================================================================
# STEP 8: Figma Sync
# STEP 10: Figma Sync
# ============================================================================
log_step "8. Figma sync..."
log_step "10. Figma sync..."
# Check if tokens are empty and Figma is available
TOKEN_STATUS=$(python3 -c "import json; d=json.load(open('.dss/data/_system/tokens/base.json')); print(d.get('_meta',{}).get('status','empty'))" 2>/dev/null || echo "empty")
if [ "$FIGMA_AVAILABLE" = true ] && [ "$TOKEN_STATUS" = "empty" ]; then
log_info "Tokens empty - syncing from Figma..."
# Get file key from config
FIGMA_FILE_KEY=$(python3 -c "import json; print(json.load(open('$FIGMA_CONFIG')).get('uikit_reference',{}).get('file_key',''))" 2>/dev/null)
if [ -n "$FIGMA_FILE_KEY" ]; then
log_info "File: $FIGMA_FILE_KEY"
# Run Figma sync script
log_info "Syncing from Figma..."
if $PYTHON "$DSS_ROOT/scripts/figma-sync.py" --file-key "$FIGMA_FILE_KEY" 2>&1 | while read line; do
echo " $line"
done; then
log_ok "Figma sync complete"
else
log_warn "Figma sync had issues - check output above"
fi
else
log_warn "No UIKit file_key in config - add to .dss/config/figma.json"
log_warn "No UIKit file_key configured"
fi
elif [ "$TOKEN_STATUS" != "empty" ]; then
log_ok "Tokens already synced (status: $TOKEN_STATUS)"
log_ok "Tokens already synced"
else
log_warn "FIGMA_TOKEN not set - add to .dss/config/figma.json"
log_warn "FIGMA_TOKEN not set"
fi
echo ""
# ============================================================================
# STEP 9: Resolve 3-Layer Token Cascade
# STEP 11: Resolve Token Cascade
# ============================================================================
log_step "9. Resolving 3-layer token cascade..."
log_step "11. Resolving token cascade..."
# Check if we have the 3-layer structure
HAS_PRIMITIVES=$([ -f ".dss/core/primitives.json" ] && echo "yes" || echo "no")
HAS_SKINS=$([ -d ".dss/skins/shadcn" ] && echo "yes" || echo "no")
if [ "$HAS_PRIMITIVES" = "yes" ] && [ "$HAS_SKINS" = "yes" ]; then
log_info "Resolving: Core → Skin → Theme"
if [ -f ".dss/core/primitives.json" ] && [ -d ".dss/skins/shadcn" ]; then
log_info "Core → Skin → Theme"
if $PYTHON scripts/resolve-tokens.py 2>&1 | while read line; do
echo " $line"
done; then
log_ok "Token cascade resolved"
else
log_warn "Token resolution had issues"
log_ok "Tokens resolved"
fi
else
log_warn "3-layer structure incomplete - using legacy tokens"
log_warn "3-layer structure incomplete"
fi
echo ""
# ============================================================================
# STEP 10: Build CSS with style-dictionary
# STEP 12: Build CSS
# ============================================================================
log_step "10. Building CSS from tokens..."
log_step "12. Building CSS..."
# Re-check if tokens have content (may have been resolved in step 9)
# Check tokens.json which is the style-dictionary input file
HAS_TOKENS=$(python3 -c "
import json
try:
d = json.load(open('.dss/data/_system/tokens/tokens.json'))
has_content = bool(d) # tokens.json has direct categories like typography, effect
print('yes' if has_content else 'no')
print('yes' if d else 'no')
except:
print('no')
" 2>/dev/null || echo "no")
# Find style-dictionary (local, parent, home, or global)
STYLE_DICT_CMD=""
if [ -f "$DSS_ROOT/node_modules/.bin/style-dictionary" ]; then
STYLE_DICT_CMD="$DSS_ROOT/node_modules/.bin/style-dictionary"
elif [ -f "$HOME/node_modules/.bin/style-dictionary" ]; then
STYLE_DICT_CMD="$HOME/node_modules/.bin/style-dictionary"
elif [ -f "$(dirname "$DSS_ROOT")/node_modules/.bin/style-dictionary" ]; then
STYLE_DICT_CMD="$(dirname "$DSS_ROOT")/node_modules/.bin/style-dictionary"
elif command -v style-dictionary &> /dev/null; then
STYLE_DICT_CMD="style-dictionary"
fi
if [ "$HAS_TOKENS" = "yes" ] && [ -n "$STYLE_DICT_CMD" ]; then
log_info "Running style-dictionary build..."
cd .dss/data/_system
if $STYLE_DICT_CMD build --config style-dictionary.config.json 2>&1 | grep -v "^$"; then
log_ok "CSS/SCSS/JSON generated in .dss/data/_system/themes/"
else
log_warn "style-dictionary build had issues"
log_ok "CSS generated"
fi
cd "$DSS_ROOT"
# Show what was generated
if [ -f ".dss/data/_system/themes/tokens.css" ]; then
CSS_VARS=$(grep -c "^ --" .dss/data/_system/themes/tokens.css 2>/dev/null || echo "0")
log_ok "Generated $CSS_VARS CSS variables"
log_ok "$CSS_VARS CSS variables"
fi
elif [ "$HAS_TOKENS" = "no" ]; then
log_warn "No tokens - run Figma sync first"
log_warn "No tokens - sync from Figma first"
elif [ -z "$STYLE_DICT_CMD" ]; then
log_warn "style-dictionary not found"
log_info "Install: npm install style-dictionary (in project root)"
log_warn "style-dictionary not installed"
fi
echo ""
# ============================================================================
# STEP 11: Generate Storybook Stories
# STEP 13: Generate Storybook Stories
# ============================================================================
log_step "11. Generating Storybook stories..."
log_step "13. Generating Storybook stories..."
if [ "$HAS_TOKENS" = "yes" ] && [ -f "scripts/generate-storybook.py" ]; then
log_info "Building stories from tokens..."
if $PYTHON scripts/generate-storybook.py 2>&1 | while read line; do
echo " $line"
done; then
STORY_COUNT=$(find admin-ui/src/stories -name "*.stories.js" 2>/dev/null | wc -l)
log_ok "Generated $STORY_COUNT Storybook stories"
else
log_warn "Storybook generation had issues"
log_ok "$STORY_COUNT stories generated"
fi
else
if [ "$HAS_TOKENS" = "no" ]; then
log_warn "No tokens - skipping Storybook generation"
else
log_warn "Storybook generator not found (scripts/generate-storybook.py)"
fi
log_warn "Skipping (no tokens or generator)"
fi
echo ""
# ============================================================================
# STEP 12: Regenerate Hash Manifest
# STEP 14: Update Hash Manifest
# ============================================================================
log_step "12. Updating hash manifest..."
log_step "14. Updating hashes..."
if [ -f "scripts/regenerate-core-hashes.sh" ]; then
./scripts/regenerate-core-hashes.sh 2>/dev/null
log_ok "Hash manifest updated"
else
log_warn "Hash script not found"
fi
echo ""
# ============================================================================
# STEP 15: Start Development Servers
# ============================================================================
if [ "$SKIP_SERVERS" = false ]; then
log_step "15. Starting development servers..."
pkill -f "vite.*admin-ui" 2>/dev/null || true
pkill -f "storybook.*6006" 2>/dev/null || true
sleep 1
cd "$DSS_ROOT/admin-ui"
nohup npm run dev > /tmp/dss-admin-ui.log 2>&1 &
log_info "admin-ui starting..."
nohup npm run storybook > /tmp/dss-storybook.log 2>&1 &
log_info "Storybook starting..."
cd "$DSS_ROOT"
sleep 5
if curl -s -o /dev/null -w "" http://localhost:3456 2>/dev/null; then
log_ok "admin-ui: http://localhost:3456"
else
log_warn "admin-ui not responding yet"
fi
if curl -s -o /dev/null -w "" http://localhost:6006 2>/dev/null; then
log_ok "Storybook: http://localhost:6006"
else
log_warn "Storybook not responding yet"
fi
echo ""
else
log_step "15. Skipping servers (--skip-servers)"
echo ""
fi
# ============================================================================
# SUMMARY
# ============================================================================
# Re-check token status after Figma sync
FINAL_TOKEN_STATUS=$(python3 -c "import json; d=json.load(open('.dss/data/_system/tokens/base.json')); print(d.get('_meta',{}).get('status','empty'))" 2>/dev/null || echo "empty")
FINAL_TOKEN_COUNT=$(python3 -c "import json; d=json.load(open('.dss/data/_system/tokens/base.json')); print(sum(len(v) for v in d.get('tokens',{}).values()))" 2>/dev/null || echo "0")
# Determine overall status
# Determine status
if [ -f ".dss/data/_system/themes/tokens.css" ]; then
STATUS="READY"
STATUS_MSG="admin-ui can import from .dss/data/_system/themes/"
elif [ "$FINAL_TOKEN_STATUS" = "synced" ]; then
STATUS="TOKENS SYNCED ($FINAL_TOKEN_COUNT tokens)"
STATUS_MSG="Install style-dictionary to build CSS: npm install -g style-dictionary"
elif [ "$FIGMA_AVAILABLE" = true ]; then
STATUS="AWAITING FIGMA SYNC"
STATUS_MSG="Run: dss_sync_figma or /dss-figma to populate tokens"
STATUS_MSG="Import from .dss/data/_system/themes/"
elif [ "$HAS_TOKENS" = "yes" ]; then
STATUS="TOKENS READY"
STATUS_MSG="Install style-dictionary to build CSS"
else
STATUS="AWAITING SETUP"
STATUS_MSG="Set FIGMA_TOKEN environment variable first"
STATUS="AWAITING FIGMA SYNC"
STATUS_MSG="Run: /dss-figma to populate tokens"
fi
echo "╔══════════════════════════════════════════════════════════════╗"
@@ -594,20 +612,17 @@ echo ""
echo " Status: $STATUS"
echo "$STATUS_MSG"
echo ""
echo " 3-Layer Architecture:"
echo " .dss/core/primitives.json ← Core Tailwind primitives (immutable)"
echo " .dss/skins/*/tokens.json ← Skins (semantic mappings)"
echo " .dss/themes/*.json ← Themes (brand overrides)"
echo " .dss/schema/skin-contract ← Contract for skin compatibility"
echo " Services:"
echo " admin-ui: http://localhost:3456"
echo " Storybook: http://localhost:6006"
echo ""
echo " Output:"
echo " .dss/data/_system/themes/ ← CSS output for admin-ui"
echo " .dss/data/_system/tokens/ ← Token JSON files"
echo " .dss/data/_system/themes/ ← CSS for admin-ui"
echo " .dss/data/_system/tokens/ ← Token JSON"
echo " admin-ui/src/stories/ ← Storybook stories"
echo ""
echo " Workflow:"
echo " 1. scripts/dss-init.sh --reset # Fresh start"
echo " 2. dss_sync_figma # Populate from Figma"
echo " 3. scripts/dss-init.sh # Validate + Build CSS"
echo " 4. admin-ui imports themes/ # Ready to use"
echo " Commands:"
echo " /dss-init --reset Fresh start"
echo " /dss-init Incremental update"
echo " /dss-init --servers-only Start servers"
echo ""