From 0416b231869a51a3863c8caa9319498b16678244 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sun, 23 Nov 2025 12:53:08 +0800 Subject: [PATCH] feat: add context-package.json sync to synthesis and design-sync workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Phase 6 to both synthesis.md and design-sync.md to automatically update context-package.json when artifacts are modified, preventing stale cache issues when transitioning to /workflow:plan. Changes: - synthesis.md: Add Phase 6 to sync updated role analyses to context-package - design-sync.md: Add Phase 5 to sync design system refs + role analyses This ensures: - synthesis → plan: context-package reflects synthesis enhancements - ui-design → plan: context-package includes design system references - No manual context-gather re-run needed after artifact updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../commands/workflow/brainstorm/synthesis.md | 58 +++++++++++++++++ .../workflow/ui-design/design-sync.md | 63 ++++++++++++++++++- 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/.claude/commands/workflow/brainstorm/synthesis.md b/.claude/commands/workflow/brainstorm/synthesis.md index 8453ac51..ca5ed597 100644 --- a/.claude/commands/workflow/brainstorm/synthesis.md +++ b/.claude/commands/workflow/brainstorm/synthesis.md @@ -381,6 +381,64 @@ Updated {role2}/analysis.md with Clarifications section + enhanced content - Ambiguities resolved, placeholders removed - Consistent terminology +### Phase 6: Update Context Package + +**Purpose**: Sync updated role analyses to context-package.json to avoid stale cache + +**Operations**: +```bash +context_pkg_path = ".workflow/active/WFS-{session}/.process/context-package.json" + +# 1. Read existing package +context_pkg = Read(context_pkg_path) + +# 2. Re-read brainstorm artifacts (now with synthesis enhancements) +brainstorm_dir = ".workflow/active/WFS-{session}/.brainstorming" + +# 2.1 Update guidance-specification if exists +IF exists({brainstorm_dir}/guidance-specification.md): + context_pkg.brainstorm_artifacts.guidance_specification.content = Read({brainstorm_dir}/guidance-specification.md) + context_pkg.brainstorm_artifacts.guidance_specification.updated_at = NOW() + +# 2.2 Update synthesis-specification if exists +IF exists({brainstorm_dir}/synthesis-specification.md): + IF context_pkg.brainstorm_artifacts.synthesis_output: + context_pkg.brainstorm_artifacts.synthesis_output.content = Read({brainstorm_dir}/synthesis-specification.md) + context_pkg.brainstorm_artifacts.synthesis_output.updated_at = NOW() + +# 2.3 Re-read all role analysis files +role_analysis_files = Glob({brainstorm_dir}/*/analysis*.md) +context_pkg.brainstorm_artifacts.role_analyses = [] + +FOR file IN role_analysis_files: + role_name = extract_role_from_path(file) # e.g., "ui-designer" + relative_path = file.replace({brainstorm_dir}/, "") + + context_pkg.brainstorm_artifacts.role_analyses.push({ + "role": role_name, + "files": [{ + "path": relative_path, + "type": "primary", + "content": Read(file), + "updated_at": NOW() + }] + }) + +# 3. Update metadata +context_pkg.metadata.updated_at = NOW() +context_pkg.metadata.synthesis_timestamp = NOW() + +# 4. Write back +Write(context_pkg_path, JSON.stringify(context_pkg, indent=2)) + +REPORT: "✅ Updated context-package.json with synthesis results" +``` + +**TodoWrite Update**: +```json +{"content": "Update context package with synthesis results", "status": "completed", "activeForm": "Updating context package"} +``` + ## Session Metadata Update `workflow-session.json`: diff --git a/.claude/commands/workflow/ui-design/design-sync.md b/.claude/commands/workflow/ui-design/design-sync.md index dcd03cdd..b23315fb 100644 --- a/.claude/commands/workflow/ui-design/design-sync.md +++ b/.claude/commands/workflow/ui-design/design-sync.md @@ -227,7 +227,68 @@ Write(file_path=".workflow/active/WFS-{session}/.brainstorming/ui-designer/desig content="[generated content with @ references]") ``` -### Phase 5: Completion +### Phase 5: Update Context Package + +**Purpose**: Sync design system references to context-package.json + +**Operations**: +```bash +context_pkg_path = ".workflow/active/WFS-{session}/.process/context-package.json" + +# 1. Read existing package +context_pkg = Read(context_pkg_path) + +# 2. Update brainstorm_artifacts (role analyses now contain @ design references) +brainstorm_dir = ".workflow/active/WFS-{session}/.brainstorming" +role_analysis_files = Glob({brainstorm_dir}/*/analysis*.md) + +context_pkg.brainstorm_artifacts.role_analyses = [] +FOR file IN role_analysis_files: + role_name = extract_role_from_path(file) + relative_path = file.replace({brainstorm_dir}/, "") + + context_pkg.brainstorm_artifacts.role_analyses.push({ + "role": role_name, + "files": [{ + "path": relative_path, + "type": "primary", + "content": Read(file), # Contains @ design system references + "updated_at": NOW() + }] + }) + +# 3. Add design_system_references field +context_pkg.design_system_references = { + "design_run_id": design_id, + "tokens": `${design_id}/${design_tokens_path}`, + "style_guide": `${design_id}/${style_guide_path}`, + "prototypes": selected_list.map(p => `${design_id}/prototypes/${p}.html`), + "updated_at": NOW() +} + +# 4. Optional: Add animations and layouts if they exist +IF exists({latest_design}/animation-extraction/animation-tokens.json): + context_pkg.design_system_references.animations = `${design_id}/animation-extraction/animation-tokens.json` + +IF exists({latest_design}/layout-extraction/layout-templates.json): + context_pkg.design_system_references.layouts = `${design_id}/layout-extraction/layout-templates.json` + +# 5. Update metadata +context_pkg.metadata.updated_at = NOW() +context_pkg.metadata.design_sync_timestamp = NOW() + +# 6. Write back +Write(context_pkg_path, JSON.stringify(context_pkg, indent=2)) + +REPORT: "✅ Updated context-package.json with design system references" +``` + +**TodoWrite Update**: +```json +{"content": "Update context package with design references", "status": "completed", "activeForm": "Updating context package"} +``` + +### Phase 6: Completion ```javascript TodoWrite({todos: [