Refactor workflows to enhance task attachment and execution model

- Updated auto-parallel.md to clarify the task attachment model, emphasizing the orchestration of tasks through attachment rather than delegation. Improved descriptions of phases and execution flow.
- Revised plan.md, tdd-plan.md, test-fix-gen.md, and test-gen.md to simplify lifecycle patterns, replacing detailed patterns with concise lifecycle summaries.
- Modified reference-page-generator.md to streamline the component extraction process, focusing on layout templates and removing unnecessary complexity in the operations.
- Enhanced error handling and output messages across various workflows to improve clarity and user guidance.
This commit is contained in:
catlog22
2025-11-11 19:52:58 +08:00
parent 7d77b0e6f7
commit a393d95cf9
6 changed files with 194 additions and 495 deletions

View File

@@ -10,12 +10,11 @@ auto-continue: true
## Overview
Converts design run extraction results into shareable, versioned reference package with:
Converts design run extraction results into shareable reference package with:
- Interactive multi-component preview (preview.html + preview.css)
- Component pattern extraction (component-patterns.json)
- Package metadata and documentation (metadata.json + README.md)
- Component layout templates (layout-templates.json)
**Role**: Takes existing design run (from `import-from-code` or other extraction commands) and enhances it with component analysis, preview generation, and packaging.
**Role**: Takes existing design run (from `import-from-code` or other extraction commands) and generates preview pages for easy reference.
## Usage
@@ -75,12 +74,13 @@ fi
# 4. Check required extraction files exist
required_files=(
"$design_run/style-extraction/style-1/design-tokens.json"
"$design_run/layout-extraction/layout-templates.json"
)
for file in "${required_files[@]}"; do
if [ ! -f "$file" ]; then
echo "ERROR: Required file not found: $file"
echo "HINT: Ensure design run has style extraction results"
echo "HINT: Ensure design run has style and layout extraction results"
exit 1
fi
done
@@ -118,180 +118,36 @@ echo " Output: $package_dir"
```json
[
{"content": "Phase 0: 验证和准备", "status": "completed", "activeForm": "验证参数"},
{"content": "Phase 1: 组件模式提取", "status": "in_progress", "activeForm": "提取组件模式"},
{"content": "Phase 2: 生成预览页面", "status": "pending", "activeForm": "生成预览"},
{"content": "Phase 3: 生成元数据和文档", "status": "pending", "activeForm": "生成文档"}
{"content": "Phase 1: 准备组件数据", "status": "in_progress", "activeForm": "复制布局模板"},
{"content": "Phase 2: 生成预览页面", "status": "pending", "activeForm": "生成预览"}
]
```
---
### Phase 1: Component Pattern Extraction
### Phase 1: Prepare Component Data
**Purpose**: Run Component Agent to extract UI component patterns from design run
**Purpose**: Copy layout templates to package directory (used as component reference)
**Agent Task**:
**Operations**:
```javascript
Task(ui-design-agent): `
[COMPONENT_PATTERNS_EXTRACTION]
Extract reusable UI component patterns from design run extraction results
```bash
echo "[Phase 1] Preparing component data from design run"
MODE: component-analysis | DESIGN_RUN: ${design_run} | OUTPUT: ${package_dir}
# Copy layout templates as component patterns
cp "${design_run}/layout-extraction/layout-templates.json" "${package_dir}/layout-templates.json"
## Input Files
# Verify copy
if [ ! -f "${package_dir}/layout-templates.json" ]; then
echo "ERROR: Failed to copy layout templates"
exit 1
fi
**Design Run Path**: ${design_run}
# Count components from layout templates
component_count=$(jq -r '.layout_templates | length // 0' "${package_dir}/layout-templates.json" 2>/dev/null || echo 0)
You can read ALL files in the design run directory:
- style-extraction/style-1/design-tokens.json
- animation-extraction/animation-tokens.json (if exists)
- layout-extraction/layout-templates.json (if exists)
- Source code files referenced in extraction metadata
## Extraction Strategy
**Component Identification**:
1. Scan design tokens for component-level styles (component_styles in design-tokens.json)
2. Review layout templates for component structures
3. Identify common UI component patterns (button, input, card, modal, badge, alert, etc.)
4. Extract DOM structure for each component
5. Identify CSS class patterns and variants
6. Map component states (default, hover, active, disabled, focus, error, success)
## Output Requirements
Generate 1 file: ${package_dir}/component-patterns.json
### component-patterns.json Structure:
{
"extraction_metadata": {
"package_name": "${package_name}",
"source_design_run": "${design_run}",
"extraction_time": "ISO8601 timestamp",
"files_analyzed": {
"design_tokens": "path/to/design-tokens.json",
"animation_tokens": "path/to/animation-tokens.json (if exists)",
"layout_templates": "path/to/layout-templates.json (if exists)"
},
"component_count": 8
},
"components": {
"button": {
"base_structure": {
"tag": "button",
"base_classes": ["btn"],
"attributes": {
"type": "button",
"role": "button"
}
},
"variants": {
"primary": {
"classes": ["btn-primary"],
"description": "Main call-to-action button",
"style_tokens": {
"background": "var(--color-brand-primary)",
"color": "var(--color-text-inverse)",
"padding": "var(--spacing-3) var(--spacing-6)",
"border_radius": "var(--border-radius-md)"
}
},
"secondary": {
"classes": ["btn-secondary"],
"description": "Secondary action button",
"style_tokens": {
"background": "var(--color-surface-elevated)",
"color": "var(--color-text-primary)",
"border": "1px solid var(--color-border-default)"
}
}
},
"sizes": {
"sm": {"classes": ["btn-sm"]},
"base": {"classes": []},
"lg": {"classes": ["btn-lg"]}
},
"states": {
"default": {"classes": []},
"hover": {"pseudo": ":hover"},
"active": {"pseudo": ":active"},
"disabled": {"attribute": "disabled", "classes": ["btn-disabled"]}
},
"usage_examples": [
"<button class=\"btn btn-primary\">Primary</button>",
"<button class=\"btn btn-secondary btn-lg\">Large Secondary</button>"
]
},
"input": {
"base_structure": {
"tag": "input",
"base_classes": ["input"],
"attributes": {"type": "text"}
},
"variants": {
"default": {
"classes": ["input-default"],
"description": "Standard text input",
"style_tokens": {
"border": "1px solid var(--color-border-default)",
"padding": "var(--spacing-3)",
"border_radius": "var(--border-radius-md)"
}
}
},
"states": {
"default": {"classes": []},
"focus": {"pseudo": ":focus"},
"error": {"classes": ["input-error"]},
"disabled": {"attribute": "disabled"}
},
"usage_examples": [
"<input class=\"input input-default\" type=\"text\" placeholder=\"Enter text\">"
]
},
"card": {
"base_structure": {
"tag": "div",
"base_classes": ["card"],
"children": [
{"tag": "div", "classes": ["card-header"], "optional": true},
{"tag": "div", "classes": ["card-body"]},
{"tag": "div", "classes": ["card-footer"], "optional": true}
]
},
"variants": {
"default": {
"classes": ["card-default"],
"description": "Standard elevated card",
"style_tokens": {
"background": "var(--color-surface-elevated)",
"padding": "var(--spacing-6)",
"border_radius": "var(--border-radius-lg)",
"box_shadow": "var(--shadow-md)"
}
}
},
"usage_examples": [
"<div class=\"card card-default\"><div class=\"card-body\">Content</div></div>"
]
}
}
}
## Completeness Criteria
- Extract at least 5 core component types (button, input, card, badge, alert, etc.)
- Include all variants and states for each component
- Provide usage examples for each component
- Map style tokens to component styles
## Critical Requirements
- ✅ Read design run extraction files using Read() tool
- ✅ Cross-reference design tokens with component styles
- ✅ Generate comprehensive component patterns catalog
- ✅ Use Write() to save: ${package_dir}/component-patterns.json
- ❌ NO external research or MCP calls
`
echo " ✓ Layout templates copied (${component_count} components)"
echo "[Phase 1] Component data preparation complete"
```
<!-- TodoWrite: Mark Phase 1 complete, start Phase 2 -->
@@ -299,14 +155,14 @@ Task(ui-design-agent): `
**TodoWrite**:
```json
[
{"content": "Phase 1: 组件模式提取", "status": "completed", "activeForm": "提取组件模式"},
{"content": "Phase 1: 准备组件数据", "status": "completed", "activeForm": "复制布局模板"},
{"content": "Phase 2: 生成预览页面", "status": "in_progress", "activeForm": "生成预览"}
]
```
---
### Phase 2: Preview Generation
### Phase 2: Preview Generation (Final Phase)
**Purpose**: Generate interactive multi-component preview (preview.html + preview.css)
@@ -321,7 +177,7 @@ Task(ui-design-agent): `
## Input Files (MUST READ ALL)
1. ${package_dir}/component-patterns.json (component patterns - REQUIRED)
1. ${package_dir}/layout-templates.json (component layout patterns - REQUIRED)
2. ${design_run}/style-extraction/style-1/design-tokens.json (design tokens - REQUIRED)
3. ${design_run}/animation-extraction/animation-tokens.json (optional, if exists)
@@ -340,9 +196,9 @@ Task(ui-design-agent): `
- Include font family examples
### Section 3: Components
- Render all components from component-patterns.json
- Render all components from layout-templates.json (use layout_templates field)
- Display all variants side-by-side
- Show all states (default, hover, active, disabled, focus, error)
- Show DOM structure with proper styling
- Include usage code snippets in <details> tags
### Section 4: Spacing & Layout
@@ -364,23 +220,23 @@ Task(ui-design-agent): `
- Complete standalone HTML file
- Responsive design with mobile-first approach
- Sticky navigation for sections
- Interactive state demonstrations
- Interactive component demonstrations
- Code snippets in collapsible <details> elements
- Footer with package metadata
### preview.css Structure:
- CSS Custom Properties from design-tokens.json
- Typography combination classes
- Component classes from component-patterns.json
- Component classes from layout-templates.json
- Preview page layout styles
- Interactive demo styles
## Critical Requirements
- ✅ Read ALL input files (component-patterns.json, design-tokens.json, animation-tokens.json if exists)
- ✅ Read ALL input files (layout-templates.json, design-tokens.json, animation-tokens.json if exists)
- ✅ Generate complete, interactive showcase HTML
- ✅ All CSS uses var() references to design tokens
- ✅ Display ALL components from component-patterns.json
- ✅ Display ALL variants and states for each component
- ✅ Display ALL components from layout-templates.json
- ✅ Display component DOM structures with proper styling
- ✅ Include usage code snippets
- ✅ Use Write() to save both files:
- ${package_dir}/preview.html
@@ -389,175 +245,14 @@ Task(ui-design-agent): `
`
```
<!-- TodoWrite: Mark Phase 2 complete, start Phase 3 -->
**TodoWrite**:
```json
[
{"content": "Phase 2: 生成预览页面", "status": "completed", "activeForm": "生成预览"},
{"content": "Phase 3: 生成元数据和文档", "status": "in_progress", "activeForm": "生成文档"}
]
```
---
### Phase 3: Metadata & Documentation Generation
**Purpose**: Create package metadata and documentation
**Operations**:
```bash
echo "[Phase 3] Generating package metadata and documentation"
# 1. Copy design tokens to package directory
cp "${design_run}/style-extraction/style-1/design-tokens.json" "${package_dir}/design-tokens.json"
cp "${design_run}/style-extraction/style-1/style-guide.md" "${package_dir}/style-guide.md" 2>/dev/null || true
# 2. Copy animation tokens if exists
if [ -f "${design_run}/animation-extraction/animation-tokens.json" ]; then
cp "${design_run}/animation-extraction/animation-tokens.json" "${package_dir}/animation-tokens.json"
fi
# 3. Get Git information (if in git repo)
git_commit=""
git_repo=""
if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
git_commit=$(git rev-parse HEAD 2>/dev/null || echo "")
git_repo=$(git config --get remote.origin.url 2>/dev/null || echo "")
fi
# 4. Get source path from design run metadata
source_path=$(grep -Po '"extraction_source":\s*"\K[^"]+' "${design_run}/style-extraction/style-1/design-tokens.json" 2>/dev/null || echo "code_import")
# 5. Generate metadata.json
cat > "${package_dir}/metadata.json" <<EOF
{
"packageName": "${package_name}",
"version": "1.0.0",
"generatedAt": "$(date -u +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date)",
"source": {
"type": "git",
"repository": "${git_repo}",
"commit": "${git_commit}",
"design_run": "${design_run}"
},
"description": "Style reference package extracted from design run",
"files": {
"design_tokens": "design-tokens.json",
"style_guide": "style-guide.md",
"component_patterns": "component-patterns.json",
"animation_tokens": "animation-tokens.json",
"preview_html": "preview.html",
"preview_css": "preview.css"
},
"usage": {
"command": "/workflow:ui-design:codify-style --package-name ${package_name}",
"skill_memory": "/memory:style-skill-memory ${package_name}",
"description": "Reference this package for consistent design system usage"
}
}
EOF
echo " ✓ metadata.json created"
# 6. Generate README.md
cat > "${package_dir}/README.md" <<'EOFREADME'
# ${package_name}
Style reference package with interactive component preview.
## Contents
- **design-tokens.json**: Complete design token system
- **style-guide.md**: Detailed style guide documentation
- **component-patterns.json**: Reusable component patterns
- **preview.html**: Interactive component showcase
- **preview.css**: Showcase styling
- **animation-tokens.json**: Animation tokens (if available)
- **metadata.json**: Package metadata
## Usage
### Preview Package
Open `preview.html` in a browser to view the interactive component showcase.
```bash
# Using local server
cd ${package_dir}
python -m http.server 8080
# Then open http://localhost:8080/preview.html
```
### Use in Workflow
Reference this package in UI design workflows or generate SKILL memory:
```bash
# Generate SKILL memory for easy loading
/memory:style-skill-memory ${package_name}
```
## Package Information
- **Generated**: $(date)
- **Source**: Design run extraction
- **Version**: 1.0.0
## Component Catalog
See `component-patterns.json` for complete component catalog with variants, states, and usage examples.
## Design Tokens
All design tokens are available as CSS custom properties. See `design-tokens.json` for complete token reference.
EOFREADME
echo " ✓ README.md created"
# 7. Verify all files exist
echo "[Phase 3] Verifying package files"
required_files=(
"design-tokens.json"
"component-patterns.json"
"preview.html"
"preview.css"
"metadata.json"
"README.md"
)
missing_files=()
for file in "${required_files[@]}"; do
if [ ! -f "${package_dir}/${file}" ]; then
missing_files+=("$file")
fi
done
if [ ${#missing_files[@]} -gt 0 ]; then
echo " ❌ ERROR: Missing required files: ${missing_files[*]}"
exit 1
fi
echo " ✓ All required files present"
# 8. Count component patterns (use jq for reliable parsing)
component_count=$(jq -r '.extraction_metadata.component_count // 0' "${package_dir}/component-patterns.json" 2>/dev/null || grep -c '"button"\|"input"\|"card"\|"badge"\|"alert"' "${package_dir}/component-patterns.json" 2>/dev/null || echo 0)
echo " ✓ Package complete with ${component_count} components"
```
<!-- TodoWrite: Mark all complete -->
**TodoWrite**:
```json
[
{"content": "Phase 0: 验证和准备", "status": "completed", "activeForm": "验证参数"},
{"content": "Phase 1: 组件模式提取", "status": "completed", "activeForm": "提取组件模式"},
{"content": "Phase 2: 生成预览页面", "status": "completed", "activeForm": "生成预览"},
{"content": "Phase 3: 生成元数据和文档", "status": "completed", "activeForm": "生成文档"}
{"content": "Phase 1: 准备组件数据", "status": "completed", "activeForm": "复制布局模板"},
{"content": "Phase 2: 生成预览页面", "status": "completed", "activeForm": "生成预览"}
]
```
@@ -568,47 +263,26 @@ echo " ✓ Package complete with ${component_count} components"
```
${output_dir}/
└── ${package_name}/
├── design-tokens.json # Design token system (copied from design run)
├── style-guide.md # Style guide (copied from design run)
── component-patterns.json # Component patterns (NEW)
├── animation-tokens.json # Animation tokens (optional, copied from design run)
├── preview.html # Interactive showcase (NEW)
├── preview.css # Showcase styling (NEW)
├── metadata.json # Package metadata (NEW)
└── README.md # Package documentation (NEW)
├── layout-templates.json # Layout templates (copied from design run)
├── preview.html # Interactive showcase (NEW)
── preview.css # Showcase styling (NEW)
```
## Completion Message
```
Reference package generated successfully!
Preview package generated!
Package: {package_name}
Location: {package_dir}
Generated Files:
design-tokens.json Design token system
style-guide.md Style guide documentation
✓ component-patterns.json Component catalog ({component_count} components)
✓ preview.html Interactive multi-component showcase
Files:
layout-templates.json {component_count} components
preview.html Interactive showcase
✓ preview.css Showcase styling
✓ animation-tokens.json Animation tokens {if exists: "✓" else: "○ (not found)"}
✓ metadata.json Package metadata
✓ README.md Package documentation
Preview Package:
Open the interactive showcase:
Open preview:
file://{absolute_path_to_package_dir}/preview.html
Or use a local server:
cd {package_dir}
python -m http.server 8080
# Then open http://localhost:8080/preview.html
Next Steps:
1. Review preview.html to verify components
2. Generate SKILL memory: /memory:style-skill-memory {package_name}
3. Use package as design reference in future workflows
```
## Error Handling
@@ -620,8 +294,8 @@ Next Steps:
| Missing --design-run or --package-name | Required parameters not provided | Provide both flags |
| Invalid package name | Contains uppercase, special chars | Use lowercase, alphanumeric, hyphens only |
| Design run not found | Incorrect path or design run doesn't exist | Verify design run path, run import-from-code first |
| Missing extraction files | Design run incomplete | Ensure design run has style-extraction results |
| Component extraction failed | No components found | Review design tokens for component_styles |
| Missing extraction files | Design run incomplete | Ensure design run has style-extraction and layout-extraction results |
| Layout templates copy failed | layout-templates.json not found | Run import-from-code with Layout Agent first |
| Preview generation failed | Invalid design tokens | Check design-tokens.json format |
---