Add merge-upstream workflow and documentation

- Created merge-upstream workflow configuration
- Added workflow instructions and validation checklist
- Added installer modification reference documentation
- Updated workflow manifest
This commit is contained in:
Sallvainian 2025-10-19 02:15:13 -04:00
parent 506ab11b33
commit 4cfa0f8c6f
7 changed files with 546 additions and 0 deletions

View File

@ -0,0 +1,11 @@
# merge-upstream
IT IS CRITICAL THAT YOU FOLLOW THESE STEPS - while staying in character as the current agent persona you may have loaded:
<steps CRITICAL="TRUE">
1. Always LOAD the FULL {project-root}/bmad/core/tasks/workflow.xml
2. READ its entire contents - this is the CORE OS for EXECUTING the specific workflow-config bmad/workflows/merge-upstream/workflow.yaml
3. Pass the yaml path bmad/workflows/merge-upstream/workflow.yaml as 'workflow-config' parameter to the workflow.xml instructions
4. Follow workflow.xml instructions EXACTLY as written
5. Save outputs after EACH section when generating any documents from templates
</steps>

View File

@ -1,4 +1,5 @@
name,description,module,path
"merge-upstream","Safely merge upstream repository changes while preserving critical fork modifications with automated verification and memory updates","core","bmad/workflows/merge-upstream/workflow.yaml"
"brainstorming","Facilitate interactive brainstorming sessions using diverse creative techniques. This workflow facilitates interactive brainstorming sessions using diverse creative techniques. The session is highly interactive, with the AI acting as a facilitator to guide the user through various ideation methods to generate and refine creative solutions.","core","bmad/core/workflows/brainstorming/workflow.yaml"
"party-mode","Orchestrates group discussions between all installed BMAD agents, enabling natural multi-agent conversations","core","bmad/core/workflows/party-mode/workflow.yaml"
"audit-workflow","Comprehensive workflow quality audit - validates structure, config standards, variable usage, bloat detection, and web_bundle completeness. Performs deep analysis of workflow.yaml, instructions.md, template.md, and web_bundle configuration against BMAD v6 standards.","bmb","bmad/bmb/workflows/audit-workflow/workflow.yaml"

1 name description module path
2 merge-upstream Safely merge upstream repository changes while preserving critical fork modifications with automated verification and memory updates core bmad/workflows/merge-upstream/workflow.yaml
3 brainstorming Facilitate interactive brainstorming sessions using diverse creative techniques. This workflow facilitates interactive brainstorming sessions using diverse creative techniques. The session is highly interactive, with the AI acting as a facilitator to guide the user through various ideation methods to generate and refine creative solutions. core bmad/core/workflows/brainstorming/workflow.yaml
4 party-mode Orchestrates group discussions between all installed BMAD agents, enabling natural multi-agent conversations core bmad/core/workflows/party-mode/workflow.yaml
5 audit-workflow Comprehensive workflow quality audit - validates structure, config standards, variable usage, bloat detection, and web_bundle completeness. Performs deep analysis of workflow.yaml, instructions.md, template.md, and web_bundle configuration against BMAD v6 standards. bmb bmad/bmb/workflows/audit-workflow/workflow.yaml

View File

@ -0,0 +1,182 @@
# Merge Upstream Workflow
**Version**: 1.0.0
**Author**: BMad
**Type**: Action Workflow (no document output)
## Purpose
Safely merge upstream repository changes while preserving critical fork modifications with automated verification and memory updates. This workflow provides a systematic, repeatable process for syncing with upstream repositories without losing custom code modifications.
## Use Cases
- Syncing your BMAD-METHOD fork with upstream bmad-code-org/BMAD-METHOD
- Preserving critical modifications during upstream pulls
- Maintaining cross-session memory of merge operations
- Ensuring custom modules remain functional after upstream integration
## How to Invoke
```bash
workflow merge-upstream
```
Or tell your BMAD agent:
```
Run the merge-upstream workflow
```
## Expected Inputs
**User Prompts During Execution:**
- Upstream remote name (default: `upstream`)
- Target branch name (default: `v6-alpha`)
- Confirmation before executing merge
- Conflict resolution if merge conflicts occur
**Files Referenced:**
- `claudedocs/installer-modification-reference.md` - Critical modification documentation
- `tools/cli/installers/lib/core/installer.js` - File containing critical modification
**Git State Required:**
- Clean working tree (no uncommitted changes)
- Upstream remote configured and accessible
- Current branch matches intended target branch
## Generated Outputs
**Git Artifacts:**
- Backup branch: `backup-before-pull-YYYYMMDD-HHMMSS`
- Merge commit with proper history preservation
- Updated reference documentation in `claudedocs/`
**Memory Updates:**
- **Serena MCP**: Updated `CRITICAL-installer-fork-modification` memory with merge details
- **Graphiti MCP**: New episode in `BMAD-METHOD` group with merge context
**Verification Reports:**
- Modification preservation status (preserved/manually restored)
- Module detection confirmation (all install-menu-config.yaml present)
- Merge statistics (files changed, commits integrated)
## Workflow Steps
1. **Pre-merge verification** - Verify clean git state and load reference docs
2. **Create backup branch** - Safety checkpoint with timestamp
3. **Document modification** - Update reference file in claudedocs/
4. **Verify before merge** - Confirm critical code exists pre-merge
5. **Fetch upstream** - Pull latest changes without merging
6. **Execute merge** - Merge with conflict handling guidance
7. **Verify preservation** - Confirm modification survived merge
8. **Update memories** - Save to Serena + Graphiti MCP
9. **Report completion** - Summary with next steps
## Special Requirements
**Required Tools:**
- **Git** - Version control for merge operations
- **Serena MCP** - Project memory management (must be active)
- **Graphiti MCP** - Knowledge graph memory (must be active)
**Critical File Protection:**
The workflow specifically protects:
- File: `tools/cli/installers/lib/core/installer.js`
- Lines: 913-916
- Code: Skip block for workflow instructions.md preservation
## Safety Features
- **Backup Branch**: Automatic timestamped backup before merge
- **Pre-merge Verification**: Confirms critical modifications exist before starting
- **Post-merge Verification**: Validates modifications survived merge
- **Recovery Guidance**: Step-by-step restoration if modifications lost
- **Memory Persistence**: Cross-session documentation for future reference
## Recovery Procedure
If merge fails or modifications are lost:
1. **Rollback**: `git reset --hard backup-before-pull-YYYYMMDD-HHMMSS`
2. **Restore**: Follow recovery instructions in `claudedocs/installer-modification-reference.md`
3. **Verify**: Run grep verification: `grep -A 2 "Skip workflow instructions" tools/cli/installers/lib/core/installer.js`
4. **Retry**: Execute workflow again after restoration
## Validation Checklist
After workflow completion, verify using `checklist.md`:
- 43 specific validation criteria across 7 categories
- Pre-merge setup, safety measures, merge execution
- Modification preservation, memory updates, completeness
- Module-specific validation for all 4 BMAD modules
## Next Steps After Workflow
**Optional:**
- Push to your fork: `git push origin v6-alpha`
- Submit PR to upstream to eliminate future maintenance burden
**For Future Syncs:**
- Run this workflow again when upstream has new changes
- Reference updated memories for historical context
- Use backup branches for safe rollback if needed
## Troubleshooting
**"Working tree not clean" error**
- Commit or stash uncommitted changes before running workflow
- Ensure no untracked files that should be tracked
**"Upstream remote not found"**
- Add upstream: `git remote add upstream https://github.com/bmad-code-org/BMAD-METHOD`
- Verify: `git remote -v`
**"Modification not found after merge"**
- Workflow will guide through manual restoration
- Reference file has exact code and insertion point
- Verification command confirms successful restoration
**"MCP servers not responding"**
- Ensure Serena and Graphiti MCP servers are active
- Check MCP configuration in .mcp.json
- Memory updates are critical for cross-session persistence
## Files in This Workflow
```
bmad/workflows/merge-upstream/
├── README.md # This file
├── workflow.yaml # Configuration and metadata
├── instructions.md # Step-by-step execution guide
└── checklist.md # Post-execution validation
```
## Version History
**v1.0.0** (2025-10-18)
- Initial workflow creation
- Based on successful manual merge execution
- Includes Serena + Graphiti memory integration
- Comprehensive validation checklist (43 criteria)
---
**Maintained by**: BMad
**Last Updated**: 2025-10-18
**Status**: Production Ready

View File

@ -0,0 +1,101 @@
# Merge Upstream Workflow Validation Checklist
## Pre-Merge Setup
- [ ] Git status confirmed clean working tree (no uncommitted changes)
- [ ] Current branch verified and matches target branch
- [ ] Upstream remote exists and is accessible
- [ ] Modification reference file loaded and reviewed
- [ ] Critical modification verified present before merge started
## Safety Measures
- [ ] Backup branch created with format: backup-before-pull-YYYYMMDD-HHMMSS
- [ ] Backup branch creation confirmed via `git branch` output
- [ ] Modification reference saved to claudedocs/installer-modification-reference.md
- [ ] Reference file includes: file path, line numbers, code snippet, verification command
- [ ] Reference file includes: insertion point details and recovery instructions
## Merge Execution
- [ ] Upstream changes fetched successfully from specified remote
- [ ] Merge commit statistics displayed (files changed, insertions, deletions)
- [ ] Merge strategy used: merge (not rebase) to preserve published history
- [ ] If conflicts occurred: All conflicts resolved manually
- [ ] If conflicts occurred: Critical modification preserved during resolution
- [ ] Merge commit created with proper commit hash recorded
- [ ] Git status shows clean state after merge (no unmerged paths)
## Critical Modification Preservation
- [ ] Post-merge verification executed: `grep -A 2 "Skip workflow instructions" tools/cli/installers/lib/core/installer.js`
- [ ] Verification output confirms modification exists at lines 913-916 (or nearby)
- [ ] Modification code intact: 4-line skip block for workflow instructions.md files
- [ ] If lost: Manual restoration completed following reference documentation
- [ ] If lost: Manual restoration verified with grep command
- [ ] Module detection verified: `find src/modules -name "install-menu-config.yaml"` returns all expected modules
## Memory Updates
- [ ] Serena MCP memory updated: CRITICAL-installer-fork-modification
- [ ] Serena memory includes: merge date, commit hash, backup branch name
- [ ] Serena memory includes: verification status and any conflicts encountered
- [ ] Serena memory includes: updated merge workflow history
- [ ] Graphiti MCP episode created with group_id: BMAD-METHOD
- [ ] Graphiti episode includes: merge context and upstream commits pulled
- [ ] Graphiti episode includes: modification preservation status
- [ ] Both memory systems confirmed successful storage
## Completeness
- [ ] Merge commit hash documented in completion summary
- [ ] Backup branch name documented for potential rollback
- [ ] Files changed statistics recorded (files, insertions, deletions)
- [ ] Modification preservation status documented (preserved/manually restored)
- [ ] Reference documentation location confirmed: claudedocs/installer-modification-reference.md
- [ ] Next steps provided: optional push to origin, consider PR to upstream
- [ ] Future workflow invocation command documented: `workflow merge-upstream`
## Specific Module Validation
- [ ] teachflow module install config present: src/modules/teachflow/\_module-installer/install-menu-config.yaml
- [ ] bmm module install config present: src/modules/bmm/\_module-installer/install-menu-config.yaml
- [ ] cis module install config present: src/modules/cis/\_module-installer/install-menu-config.yaml
- [ ] bmb module install config present: src/modules/bmb/\_module-installer/install-menu-config.yaml
- [ ] All workflow instructions.md files protected (28+ files in bmm module)
## Final Validation
### Pre-Merge Setup Issues
- [ ] Issue List:
### Safety Measures Issues
- [ ] Issue List:
### Merge Execution Issues
- [ ] Issue List:
### Critical Modification Preservation Issues
- [ ] Issue List:
### Memory Updates Issues
- [ ] Issue List:
### Completeness Issues
- [ ] Issue List:
### Module Validation Issues
- [ ] Issue List:
---
**Workflow Status**: [ ] Complete and Validated
**Signed off by**: **\*\*\*\***\_**\*\*\*\*** **Date**: **\*\*\*\***\_**\*\*\*\***

View File

@ -0,0 +1,169 @@
# Merge Upstream Workflow Instructions
<critical>The workflow execution engine is governed by: {project-root}/bmad/core/tasks/workflow.xml</critical>
<critical>You MUST have already loaded and processed: {project-root}/bmad/workflows/merge-upstream/workflow.yaml</critical>
<critical>Communicate in {communication_language} throughout the workflow process</critical>
<workflow>
<step n="1" goal="Pre-merge verification and setup">
<action>Verify git repository status to ensure a clean working tree before beginning merge</action>
<action>Check current branch and confirm it matches the expected target branch</action>
<action>Identify the upstream remote and target branch to merge from</action>
<ask>What is the upstream remote name? (default: upstream)</ask>
<ask>What branch should we merge from upstream? (default: v6-alpha)</ask>
<action>Verify the upstream remote exists and is accessible</action>
<check if="working tree not clean">
<action>Alert user about uncommitted changes that must be resolved first</action>
<action>Provide guidance: commit changes, stash them, or clean the working directory</action>
<goto step="1">Wait for user to resolve before continuing</goto>
</check>
<action>Load the modification reference documentation from: {modification_reference}</action>
<action>Review critical file locations and modification details that must be preserved</action>
</step>
<step n="2" goal="Create safety backup branch">
<action>Generate a timestamped backup branch name using format: backup-before-pull-YYYYMMDD-HHMMSS</action>
<action>Create the backup branch from current HEAD as a safety checkpoint</action>
<action>Verify backup branch was created successfully</action>
<action>Inform user of backup branch name for potential rollback</action>
<critical>This backup branch is essential for recovery if the merge encounters unexpected issues</critical>
</step>
<step n="3" goal="Document critical modification for reference">
<action>Create or update the modification reference file in claudedocs/ directory</action>
<action>Document the exact code that must be preserved during merge</action>
<action>Include file path, line numbers, and the critical code snippet</action>
<action>Add insertion point details and recovery instructions</action>
<action>Save verification commands for post-merge checking</action>
<example>
Reference file should include:
- File: tools/cli/installers/lib/core/installer.js
- Lines: 913-916
- Code: Skip block for workflow instructions.md
- Verification: grep command to check presence
</example>
</step>
<step n="4" goal="Verify modification exists before merge">
<action>Execute verification command to confirm critical modification is present</action>
<action>Use grep to search for the modification signature in the target file</action>
<critical>Command: grep -A 2 "Skip workflow instructions" tools/cli/installers/lib/core/installer.js</critical>
<check if="modification not found">
<action>Alert user that critical modification is missing from current codebase</action>
<action>Provide guidance on restoring the modification before attempting merge</action>
<goto step="1">Halt until modification is restored</goto>
</check>
<action>Confirm modification present at expected location</action>
<action>Record current line numbers for post-merge comparison</action>
</step>
<step n="5" goal="Fetch upstream changes">
<action>Fetch latest changes from upstream remote without merging</action>
<action>Display summary of incoming changes: commits, files, insertions/deletions</action>
<action>Review commit messages from upstream to understand what's being integrated</action>
<critical>Command: git fetch {{upstream_remote}} {{target_branch}}</critical>
<action if="fetch fails">Alert user about network issues or remote access problems</action>
</step>
<step n="6" goal="Execute merge with safety checks">
<action>Explain merge strategy: using merge (not rebase) to preserve published history</action>
<action>Display number of divergent commits between local and upstream</action>
<ask>Ready to proceed with merge? Review upstream changes above. [yes/no]</ask>
<check if="user declines">
<action>Inform user they can review changes and restart workflow when ready</action>
<action>Remind user of backup branch location for safety</action>
<goto step="END">Exit workflow</goto>
</check>
<action>Execute merge command: git merge {{upstream_remote}}/{{target_branch}}</action>
<check if="merge conflicts occur">
<action>Display conflict files and conflict markers</action>
<action>Guide user through conflict resolution, emphasizing preservation of critical modification</action>
<action>Provide specific guidance for installer.js conflicts if present</action>
<ask>Have you resolved all conflicts? [yes/no]</ask>
<action if="conflicts resolved">Verify modification preserved during resolution</action>
<action if="conflicts not resolved">Wait for user to complete resolution</action>
</check>
<action>Record merge commit hash for documentation</action>
<action>Display merge statistics: files changed, insertions, deletions</action>
</step>
<step n="7" goal="Verify modification preservation">
<action>Execute post-merge verification to confirm critical modification survived</action>
<critical>Command: grep -A 2 "Skip workflow instructions" tools/cli/installers/lib/core/installer.js</critical>
<check if="modification not found">
<action>Alert user that critical modification was lost during merge</action>
<action>Load recovery instructions from reference documentation</action>
<action>Guide user to manually re-insert the 4-line modification after config.yaml skip block</action>
<action>Verify manual restoration before continuing</action>
</check>
<action>Confirm modification exists at same or nearby line numbers</action>
<action>Verify git status shows clean merge completion</action>
<action>Check that all expected modules still have install-menu-config.yaml files</action>
<critical>Verification: find src/modules -name "install-menu-config.yaml" should show all modules intact</critical>
</step>
<step n="8" goal="Update cross-session memories">
<action>Prepare comprehensive memory update for Serena MCP with merge details</action>
<action>Include merge date, commit hash, backup branch name, verification results</action>
<action>Document any conflicts encountered and how they were resolved</action>
<action>Update merge workflow history and success metrics</action>
<action>Write updated memory to Serena: CRITICAL-installer-fork-modification</action>
<action>Prepare episode for Graphiti MCP knowledge graph</action>
<action>Include merge context, upstream commits pulled, modification preservation status</action>
<action>Link to related entities: installer.js, modules, git workflow</action>
<action>Add merge episode to Graphiti with group_id: BMAD-METHOD</action>
<action>Verify both memory systems confirm successful storage</action>
</step>
<step n="9" goal="Report completion and next steps">
<action>Generate comprehensive merge completion summary for {user_name}</action>
<action>Include in summary:
- Merge status (success/conflicts resolved)
- Backup branch name and location
- Merge commit hash
- Files changed statistics
- Modification preservation status (preserved/manually restored)
- Memory update confirmations (Serena + Graphiti)
- Reference documentation location
</action>
<action>Provide next steps guidance:
- Optional: Push to origin fork (git push origin {{target_branch}})
- Consider: Submit PR to upstream to eliminate future maintenance
- Future: Use this workflow for subsequent upstream syncs
</action>
<action>Remind user of verification commands for future reference</action>
<critical>Workflow complete! All critical modifications preserved and documented.</critical>
</step>
</workflow>

View File

@ -0,0 +1,32 @@
# Merge Upstream Workflow Configuration
name: "merge-upstream"
description: "Safely merge upstream repository changes while preserving critical fork modifications with automated verification and memory updates"
author: "BMad"
# Critical variables from config
config_source: "{project-root}/bmad/core/config.yaml"
output_folder: "{config_source}:output_folder"
user_name: "{config_source}:user_name"
communication_language: "{config_source}:communication_language"
date: system-generated
# Module path and component files
installed_path: "{project-root}/bmad/workflows/merge-upstream"
template: false # This is an action workflow - no template needed
instructions: "{installed_path}/instructions.md"
validation: "{installed_path}/checklist.md"
# Reference documentation
modification_reference: "{project-root}/claudedocs/installer-modification-reference.md"
# Tool Requirements
required_tools:
- "Git":
description: "Version control system for merge operations"
link: "https://git-scm.com/"
- "Serena MCP":
description: "Project memory management for cross-session persistence"
link: "MCP server for project context"
- "Graphiti MCP":
description: "Knowledge graph memory for relationship tracking"
link: "MCP server for graph-based memory"

View File

@ -0,0 +1,50 @@
# Critical Installer Modification Reference
**Date**: 2025-10-18
**File**: `tools/cli/installers/lib/core/installer.js`
**Lines**: 913-916
**Backup Branch**: backup-before-pull-20251018-133852
## Modification Code
```javascript
// Skip workflow instructions.md files to preserve user customizations
if (file.includes('workflows/') && file.endsWith('instructions.md')) {
continue;
}
```
## Insertion Point
This code MUST be inserted in the `copyDirectoryWithFiltering()` method, immediately after the config.yaml skip block:
```javascript
// Skip config.yaml templates - we'll generate clean ones with actual values
if (file === 'config.yaml' || file.endsWith('/config.yaml')) {
continue;
}
// ← INSERT THE 4-LINE MODIFICATION HERE
const sourceFile = path.join(sourcePath, file);
```
## Purpose
- Prevents workflow instructions.md files from being overwritten during updates
- Essential for teachflow module to be detected by ModuleManager.listAvailable()
- Without this, user customizations in workflow instructions are lost
## Verification Command
```bash
grep -A 2 "Skip workflow instructions" tools/cli/installers/lib/core/installer.js
```
Expected output:
```
// Skip workflow instructions.md files to preserve user customizations
if (file.includes('workflows/') && file.endsWith('instructions.md')) {
continue;
```