mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat: v4.2.0 - Enhance multi-page support with improved prompt parsing, cross-page consistency validation, and user confirmation mechanisms
This commit is contained in:
@@ -155,21 +155,161 @@ ELSE:
|
||||
STORE: run_id, base_path # Use throughout workflow
|
||||
```
|
||||
|
||||
### Phase 0c: Page Inference
|
||||
### Phase 0c: Enhanced Page Inference with Dynamic Analysis
|
||||
```bash
|
||||
# Infer page list if not explicitly provided
|
||||
# Initialize
|
||||
page_list = []
|
||||
page_source = "none"
|
||||
page_structure = null # Store structured analysis results
|
||||
|
||||
# Priority 1: Explicit --pages parameter (with enhanced cleaning)
|
||||
IF --pages provided:
|
||||
page_list = parse_csv({--pages value})
|
||||
# Enhanced cleaning: tolerate spaces, multiple delimiters
|
||||
raw_pages = {--pages value}
|
||||
# Split by comma, semicolon, or Chinese comma, then clean each
|
||||
page_list = split_and_clean(raw_pages, delimiters=[",", ";", "、"])
|
||||
# Strip whitespace, convert to lowercase, replace spaces with hyphens
|
||||
page_list = [p.strip().lower().replace(" ", "-") for p in page_list if p.strip()]
|
||||
page_source = "explicit"
|
||||
REPORT: "📋 Using explicitly provided pages: {', '.join(page_list)}"
|
||||
|
||||
# Priority 2: Dynamic prompt decomposition (using Claude's analysis)
|
||||
ELSE IF --prompt provided:
|
||||
# Extract page names from prompt (e.g., "blog with home, article, author pages")
|
||||
page_list = extract_pages_from_prompt({--prompt value})
|
||||
REPORT: "🔍 Analyzing prompt to identify pages..."
|
||||
|
||||
# Use main Claude to analyze prompt structure
|
||||
analysis_prompt = """
|
||||
Analyze the following UI design request and identify all distinct pages/screens needed.
|
||||
|
||||
User Request: "{prompt_text}"
|
||||
|
||||
Output a JSON object with this structure:
|
||||
{
|
||||
"pages": [
|
||||
{"name": "page-name", "purpose": "brief description", "priority": "high|medium|low"}
|
||||
],
|
||||
"shared_components": ["header", "footer", "sidebar"],
|
||||
"navigation_structure": {
|
||||
"primary": ["home", "dashboard"],
|
||||
"secondary": ["settings", "profile"]
|
||||
}
|
||||
}
|
||||
|
||||
Rules:
|
||||
- Normalize page names to be URL-friendly (lowercase, use hyphens, no spaces)
|
||||
- Consolidate synonyms (e.g., "homepage" → "home", "user-profile" → "profile")
|
||||
- Identify hierarchical relationships if mentioned
|
||||
- Prioritize pages based on user intent
|
||||
- Common page patterns: home, dashboard, settings, profile, login, signup, about, contact
|
||||
"""
|
||||
|
||||
# Execute analysis (internal to main Claude, no external tool needed)
|
||||
page_structure = analyze_prompt_structure(analysis_prompt, prompt_text)
|
||||
page_list = extract_page_names_from_structure(page_structure)
|
||||
page_source = "prompt_analysis"
|
||||
|
||||
# Display analysis results
|
||||
IF page_list:
|
||||
REPORT: "📋 Identified pages from prompt:"
|
||||
FOR each page IN page_structure.pages:
|
||||
REPORT: " • {page.name}: {page.purpose} [{page.priority}]"
|
||||
|
||||
IF page_structure.shared_components:
|
||||
REPORT: "🔧 Shared components: {', '.join(page_structure.shared_components)}"
|
||||
ELSE:
|
||||
REPORT: "⚠️ No pages could be extracted from the prompt."
|
||||
|
||||
# Priority 3: Extract from synthesis-specification.md
|
||||
ELSE IF --session AND exists(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md):
|
||||
synthesis = Read(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md)
|
||||
page_list = extract_pages_from_synthesis(synthesis)
|
||||
ELSE:
|
||||
page_list = ["home"] # Default fallback
|
||||
page_source = "synthesis"
|
||||
REPORT: "📋 Extracted pages from synthesis: {', '.join(page_list)}"
|
||||
|
||||
STORE: inferred_page_list = page_list # For Phase 3
|
||||
# Priority 4: Final fallback - default page
|
||||
IF NOT page_list:
|
||||
page_list = ["home"]
|
||||
page_source = "default"
|
||||
REPORT: "⚠️ No pages identified, using default: 'home'"
|
||||
|
||||
# Enhanced validation
|
||||
validated_pages = []
|
||||
invalid_pages = []
|
||||
FOR page IN page_list:
|
||||
# Clean: strip, lowercase, replace spaces with hyphens
|
||||
cleaned_page = page.strip().lower().replace(" ", "-")
|
||||
# Validate: must start with letter/number, can contain letters, numbers, hyphens, underscores
|
||||
IF regex_match(cleaned_page, r"^[a-z0-9][a-z0-9_-]*$"):
|
||||
validated_pages.append(cleaned_page)
|
||||
ELSE:
|
||||
invalid_pages.append(page)
|
||||
|
||||
IF invalid_pages:
|
||||
REPORT: "⚠️ Skipped invalid page names: {', '.join(invalid_pages)}"
|
||||
REPORT: " Valid format: lowercase, alphanumeric, hyphens, underscores (e.g., 'user-profile', 'dashboard')"
|
||||
|
||||
IF NOT validated_pages:
|
||||
validated_pages = ["home"]
|
||||
REPORT: "⚠️ All page names invalid, using default: 'home'"
|
||||
|
||||
# Interactive confirmation step
|
||||
REPORT: ""
|
||||
REPORT: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
REPORT: "📌 PAGE LIST CONFIRMATION"
|
||||
REPORT: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
REPORT: "Source: {page_source}"
|
||||
REPORT: "Pages to generate ({len(validated_pages)}): {', '.join(validated_pages)}"
|
||||
REPORT: ""
|
||||
REPORT: "⏸️ Please confirm or modify the page list:"
|
||||
REPORT: ""
|
||||
REPORT: "Options:"
|
||||
REPORT: " • Type 'continue' or 'yes' to proceed with these pages"
|
||||
REPORT: " • Type 'pages: page1, page2, page3' to replace the entire list"
|
||||
REPORT: " • Type 'skip: page-name' to remove specific pages"
|
||||
REPORT: " • Type 'add: page-name' to add specific pages"
|
||||
REPORT: ""
|
||||
REPORT: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
# Wait for user input
|
||||
user_confirmation = WAIT_FOR_USER_INPUT()
|
||||
|
||||
# Process user input
|
||||
IF user_confirmation MATCHES r"^(continue|yes|ok|proceed)$":
|
||||
REPORT: "✅ Proceeding with: {', '.join(validated_pages)}"
|
||||
ELSE IF user_confirmation MATCHES r"^pages:\s*(.+)$":
|
||||
# User provided new page list
|
||||
new_pages_raw = extract_after_prefix(user_confirmation, "pages:")
|
||||
new_pages = split_and_clean(new_pages_raw, delimiters=[",", ";", "、"])
|
||||
validated_pages = [p.strip().lower().replace(" ", "-") for p in new_pages if p.strip()]
|
||||
REPORT: "✅ Updated page list: {', '.join(validated_pages)}"
|
||||
ELSE IF user_confirmation MATCHES r"^skip:\s*(.+)$":
|
||||
# Remove specified pages
|
||||
pages_to_skip_raw = extract_after_prefix(user_confirmation, "skip:")
|
||||
pages_to_skip = [p.strip().lower() for p in pages_to_skip_raw.split(",")]
|
||||
validated_pages = [p for p in validated_pages if p not in pages_to_skip]
|
||||
REPORT: "✅ Removed pages: {', '.join(pages_to_skip)}"
|
||||
REPORT: " Final list: {', '.join(validated_pages)}"
|
||||
ELSE IF user_confirmation MATCHES r"^add:\s*(.+)$":
|
||||
# Add specified pages
|
||||
pages_to_add_raw = extract_after_prefix(user_confirmation, "add:")
|
||||
pages_to_add = [p.strip().lower().replace(" ", "-") for p in pages_to_add_raw.split(",") if p.strip()]
|
||||
validated_pages.extend(pages_to_add)
|
||||
# Remove duplicates while preserving order
|
||||
validated_pages = list(dict.fromkeys(validated_pages))
|
||||
REPORT: "✅ Added pages: {', '.join(pages_to_add)}"
|
||||
REPORT: " Final list: {', '.join(validated_pages)}"
|
||||
ELSE:
|
||||
REPORT: "⚠️ Invalid input format, proceeding with original list: {', '.join(validated_pages)}"
|
||||
|
||||
# Final verification
|
||||
IF NOT validated_pages:
|
||||
validated_pages = ["home"]
|
||||
REPORT: "⚠️ Empty page list detected, using default: 'home'"
|
||||
|
||||
# Store results for subsequent phases
|
||||
STORE: inferred_page_list = validated_pages # For Phase 3
|
||||
STORE: page_inference_source = page_source # Track source for metadata
|
||||
STORE: page_structure_data = page_structure # Save structured data for future use
|
||||
```
|
||||
|
||||
### Phase 1: Style Extraction
|
||||
@@ -216,10 +356,26 @@ command = "/workflow:ui-design:consolidate {run_base_flag} --variants {style_var
|
||||
**Command Construction**:
|
||||
```bash
|
||||
run_base_flag = "--base-path \"{base_path}/.design\""
|
||||
pages_flag = "--pages \"{inferred_page_list}\""
|
||||
|
||||
# Ensure inferred_page_list is serialized correctly as comma-separated string
|
||||
# Convert list to string: ['dashboard', 'settings'] → "dashboard,settings"
|
||||
pages_string = ",".join(inferred_page_list)
|
||||
|
||||
# Validate the serialized string format
|
||||
VERIFY: pages_string matches r"^[a-z0-9_-]+(,[a-z0-9_-]+)*$"
|
||||
|
||||
pages_flag = "--pages \"{pages_string}\""
|
||||
|
||||
# Matrix mode is default in generate.md, no mode flag needed
|
||||
command = "/workflow:ui-design:generate {run_base_flag} {pages_flag} --style-variants {style_variants} --layout-variants {layout_variants}"
|
||||
|
||||
# Log command for debugging
|
||||
REPORT: "🚀 Executing Phase 3: Matrix UI Generation"
|
||||
REPORT: " Pages: {pages_string}"
|
||||
REPORT: " Style variants: {style_variants}"
|
||||
REPORT: " Layout variants: {layout_variants}"
|
||||
REPORT: " Total prototypes: {style_variants * layout_variants * len(inferred_page_list)}"
|
||||
|
||||
SlashCommand(command=command)
|
||||
```
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Generate production-ready UI prototypes (HTML/CSS) in `style × layout` matrix m
|
||||
|
||||
## Execution Protocol
|
||||
|
||||
### Phase 1: Path Resolution & Context Loading
|
||||
### Phase 1: Path Resolution & Context Loading (Enhanced)
|
||||
```bash
|
||||
# Determine base path
|
||||
IF --base-path provided:
|
||||
@@ -42,18 +42,63 @@ layout_variants = --layout-variants OR 3 # Default to 3
|
||||
VALIDATE: 1 <= style_variants <= 5
|
||||
VALIDATE: 1 <= layout_variants <= 5
|
||||
|
||||
# Infer page list if not provided
|
||||
# Enhanced page list parsing
|
||||
page_list = []
|
||||
page_source = "none"
|
||||
|
||||
# Priority 1: Explicit --pages parameter (with robust parsing)
|
||||
IF --pages provided:
|
||||
page_list = parse_csv({--pages value})
|
||||
# Enhanced parsing: handle spaces, multiple delimiters
|
||||
raw_pages = {--pages value}
|
||||
|
||||
# Split by comma, semicolon, or Chinese comma, then clean
|
||||
page_list = split_and_clean(raw_pages, delimiters=[",", ";", "、"])
|
||||
|
||||
# Clean each page name: strip whitespace, convert to lowercase
|
||||
page_list = [p.strip().lower().replace(" ", "-") for p in page_list if p.strip()]
|
||||
|
||||
page_source = "explicit_parameter"
|
||||
REPORT: "📋 Using provided pages: {', '.join(page_list)}"
|
||||
|
||||
# Priority 2: Extract from synthesis-specification.md
|
||||
ELSE IF --session:
|
||||
# Read synthesis-specification.md to extract page requirements
|
||||
synthesis_spec = Read(.workflow/WFS-{session}/.brainstorming/synthesis-specification.md)
|
||||
page_list = extract_pages_from_synthesis(synthesis_spec)
|
||||
page_source = "synthesis_specification"
|
||||
REPORT: "📋 Extracted pages from synthesis: {', '.join(page_list)}"
|
||||
|
||||
# Priority 3: Detect from existing prototypes
|
||||
ELSE:
|
||||
# Infer from existing prototypes or default
|
||||
page_list = detect_from_prototypes({base_path}/prototypes/) OR ["home"]
|
||||
page_list = detect_from_prototypes({base_path}/prototypes/)
|
||||
IF page_list:
|
||||
page_source = "existing_prototypes"
|
||||
REPORT: "📋 Detected pages from existing prototypes: {', '.join(page_list)}"
|
||||
ELSE:
|
||||
page_list = ["home"]
|
||||
page_source = "default"
|
||||
REPORT: "⚠️ No pages found, using default: 'home'"
|
||||
|
||||
VALIDATE: page_list not empty
|
||||
# Validation: ensure page names are valid
|
||||
validated_pages = []
|
||||
invalid_pages = []
|
||||
FOR page IN page_list:
|
||||
# Validate format: must start with letter/number, can contain alphanumeric, hyphens, underscores
|
||||
IF regex_match(page, r"^[a-z0-9][a-z0-9_-]*$"):
|
||||
validated_pages.append(page)
|
||||
ELSE:
|
||||
invalid_pages.append(page)
|
||||
|
||||
IF invalid_pages:
|
||||
REPORT: "⚠️ Skipped invalid page names: {', '.join(invalid_pages)}"
|
||||
REPORT: " Valid format: lowercase, alphanumeric, hyphens, underscores"
|
||||
|
||||
VALIDATE: validated_pages not empty, "No valid pages found"
|
||||
|
||||
# Use validated list
|
||||
page_list = validated_pages
|
||||
REPORT: "✅ Final page list ({len(page_list)}): {', '.join(page_list)}"
|
||||
|
||||
# Verify design systems exist for all styles
|
||||
FOR style_id IN range(1, style_variants + 1):
|
||||
@@ -346,6 +391,109 @@ Refer to corresponding `style-guide.md` for design philosophy and usage guidelin
|
||||
4. Run `/workflow:ui-design:update` to integrate chosen designs
|
||||
```
|
||||
|
||||
### Phase 3.5: Cross-Page Consistency Validation (Optional, Multi-Page Only)
|
||||
**Condition**: Only executes if `len(page_list) > 1`
|
||||
|
||||
```bash
|
||||
# Skip if only one page
|
||||
IF len(page_list) <= 1:
|
||||
SKIP to Phase 4
|
||||
|
||||
# For multi-page workflows, validate cross-page consistency
|
||||
FOR style_id IN range(1, style_variants + 1):
|
||||
FOR layout_id IN range(1, layout_variants + 1):
|
||||
# Generate consistency report for this style-layout combo across all pages
|
||||
Task(conceptual-planning-agent): "
|
||||
[CROSS_PAGE_CONSISTENCY_VALIDATION]
|
||||
|
||||
Validate design consistency across multiple pages for Style-{style_id} Layout-{layout_id}
|
||||
|
||||
## Context
|
||||
STYLE_ID: {style_id}
|
||||
LAYOUT_ID: {layout_id}
|
||||
PAGES: {page_list}
|
||||
BASE_PATH: {base_path}
|
||||
|
||||
## Input Files
|
||||
FOR each page IN {page_list}:
|
||||
- {base_path}/prototypes/{page}-style-{style_id}-layout-{layout_id}.html
|
||||
- {base_path}/prototypes/{page}-style-{style_id}-layout-{layout_id}.css
|
||||
|
||||
## Validation Tasks
|
||||
1. **Shared Component Consistency**:
|
||||
- Check if header/navigation structure is identical across all pages
|
||||
- Verify footer content and styling matches
|
||||
- Confirm common UI elements (buttons, forms, cards) use same classes/styles
|
||||
|
||||
2. **Token Usage Consistency**:
|
||||
- Verify all pages reference the same design-tokens file
|
||||
- Confirm CSS variable usage is consistent (no hardcoded values)
|
||||
- Check spacing, typography, and color token application
|
||||
|
||||
3. **Accessibility Consistency**:
|
||||
- Validate ARIA attributes are used consistently
|
||||
- Check heading hierarchy (h1 unique per page, h2-h6 consistent)
|
||||
- Verify landmark roles are consistent
|
||||
|
||||
4. **Layout Strategy Adherence**:
|
||||
- Confirm Layout-{layout_id} strategy is applied consistently to all pages
|
||||
- Check responsive breakpoints are identical
|
||||
- Verify grid/flex systems match across pages
|
||||
|
||||
## Output Format
|
||||
Generate a consistency report: {base_path}/prototypes/consistency-report-s{style_id}-l{layout_id}.md
|
||||
|
||||
```markdown
|
||||
# Cross-Page Consistency Report
|
||||
**Style**: {style_id} | **Layout**: {layout_id} | **Pages**: {', '.join(page_list)}
|
||||
|
||||
## ✅ Passed Checks
|
||||
- [List consistency checks that passed]
|
||||
|
||||
## ⚠️ Warnings
|
||||
- [List minor inconsistencies that should be reviewed]
|
||||
|
||||
## ❌ Issues
|
||||
- [List critical inconsistencies that must be fixed]
|
||||
|
||||
## Recommendations
|
||||
- [Suggestions for improving consistency]
|
||||
```
|
||||
|
||||
## Severity Levels
|
||||
- **Critical**: Shared components have different structure/styling
|
||||
- **Warning**: Minor variations in spacing or naming
|
||||
- **Info**: Intentional page-specific adaptations
|
||||
|
||||
IMPORTANT: Focus on truly shared elements (header, nav, footer). Page-specific content variations are expected and acceptable.
|
||||
"
|
||||
|
||||
# Aggregate all consistency reports
|
||||
Write({base_path}/prototypes/CONSISTENCY_SUMMARY.md):
|
||||
# Multi-Page Consistency Summary
|
||||
|
||||
This report summarizes consistency validation across all {len(page_list)} pages.
|
||||
|
||||
## Validated Combinations
|
||||
- **Style Variants**: {style_variants}
|
||||
- **Layout Variants**: {layout_variants}
|
||||
- **Total Reports**: {style_variants * layout_variants}
|
||||
|
||||
## Report Files
|
||||
{FOR s IN range(1, style_variants + 1):
|
||||
{FOR l IN range(1, layout_variants + 1):
|
||||
- [Style {s} Layout {l}](./consistency-report-s{s}-l{l}.md)
|
||||
}
|
||||
}
|
||||
|
||||
## Quick Actions
|
||||
1. Review all consistency reports
|
||||
2. Fix critical issues before proceeding to implementation
|
||||
3. Document intentional page-specific variations
|
||||
|
||||
Run `/workflow:ui-design:update` once all issues are resolved.
|
||||
```
|
||||
|
||||
### Phase 4: TodoWrite & Completion
|
||||
|
||||
```javascript
|
||||
|
||||
Reference in New Issue
Block a user