UNPKG

@cloudkinetix/bmad-enhanced

Version:

Cloud-Kinetix enhanced fork of BMAD-METHOD - Breakthrough Method of Agile AI-driven Development with robust versioning and unified validation.

287 lines (234 loc) 7.62 kB
--- name: LLM-Native Dependency Analyzer version: 1.0.0 role: Analyze semantic dependencies for parallel development description: Provides intelligent dependency analysis using LLM reasoning capabilities to understand code purpose, architectural patterns, and business logic connections capabilities: - Semantic dependency detection - Hidden conflict identification - Risk-based planning - Platform-agnostic analysis - Architectural impact assessment --- # LLM-Native Dependency Analyzer ## Purpose Provides intelligent dependency analysis using LLM reasoning capabilities instead of script-based file scanning. This analyzer understands semantic dependencies, architectural patterns, and business logic connections between work items. ## Core Capabilities ### 1. Semantic Dependency Detection - **Code Understanding**: Analyzes code purpose and functionality - **API Contract Analysis**: Identifies interface dependencies - **Data Flow Tracking**: Understands how data moves through the system - **Business Logic Dependencies**: Recognizes functional relationships ### 2. Intelligent Conflict Prediction - **Direct Conflicts**: Files/functions that will be modified - **Indirect Conflicts**: Cascading effects of changes - **Integration Points**: Shared interfaces and contracts - **Test Dependencies**: Test suites affected by changes ### 3. Risk Assessment - **Merge Conflict Probability**: Based on code overlap - **Integration Risk**: Based on API changes - **Testing Risk**: Based on test coverage impact - **Architecture Risk**: Based on structural changes ## Analysis Framework ### Input Structure ```json { "workItems": [ { "id": "story-1", "description": "Add user authentication system", "type": "feature", "technicalDetails": "Implement JWT-based auth with refresh tokens" }, { "id": "story-2", "description": "Update user profile management", "type": "enhancement", "technicalDetails": "Add profile picture upload and validation" } ], "codebaseContext": { "architecture": "microservices|monolithic|serverless", "primaryLanguage": "javascript|python|java", "testingFramework": "jest|pytest|junit", "keyComponents": ["auth-service", "user-service", "api-gateway"] } } ``` ### Analysis Prompt Template ```markdown You are an expert software architect analyzing dependencies between work items for parallel development. Your goal is to identify all dependencies - both obvious and subtle - that could cause conflicts or issues if these items are developed simultaneously. ## Work Items to Analyze: [List each work item with description and technical details] ## Codebase Context: [Provide architecture, language, and component information] ## Analysis Tasks: 1. **File-Level Dependencies** - List specific files/modules each work item will likely modify - Identify shared files between work items - Note configuration files that might be touched 2. **Semantic Dependencies** - API contracts that multiple items depend on - Shared data models or schemas - Common utility functions or services - Database tables or collections affected 3. **Architectural Dependencies** - Service boundaries crossed - Communication patterns affected - Infrastructure components impacted - Security or authentication flows modified 4. **Testing Dependencies** - Test files that will need updates - Integration tests affected - Test data or fixtures that might conflict - Testing infrastructure changes needed 5. **Risk Assessment** For each dependency found: - Conflict probability: HIGH/MEDIUM/LOW - Impact severity: CRITICAL/MAJOR/MINOR - Mitigation strategy: How to resolve if both proceed 6. **Parallelization Recommendation** Based on your analysis, recommend: - Which items can safely run in parallel - Which must be sequenced and in what order - Which might benefit from closer coordination Provide your analysis in a structured format that can be parsed programmatically. ``` ### Output Structure ```json { "dependencyMatrix": { "story-1": { "story-2": { "conflictLevel": "MEDIUM", "sharedResources": ["user-model", "auth-middleware"], "riskFactors": ["Both modify authentication flow"], "recommendation": "Sequence with story-1 first" } } }, "fileConflicts": [ { "file": "src/models/user.js", "affectedBy": ["story-1", "story-2"], "conflictType": "schema-modification", "severity": "HIGH" } ], "semanticDependencies": [ { "type": "api-contract", "description": "User authentication endpoint", "affectedStories": ["story-1", "story-2"], "impact": "Breaking change requires coordination" } ], "executionPlan": { "waves": [ { "wave": 1, "parallel": ["story-3", "story-4"], "reasoning": "No shared dependencies" }, { "wave": 2, "parallel": ["story-1"], "reasoning": "Establishes auth foundation" }, { "wave": 3, "parallel": ["story-2"], "reasoning": "Depends on auth from wave 2" } ] } } ``` ## Integration with Parallel Development ### 1. Pre-Execution Analysis ```markdown Before starting parallel development: 1. Gather work item descriptions and technical details 2. Run LLM dependency analysis 3. Generate conflict matrix and risk assessment 4. Create optimized wave execution plan 5. Present findings for approval ``` ### 2. Continuous Monitoring ```markdown During parallel execution: 1. Monitor for unexpected dependencies 2. Re-analyze if scope changes 3. Adjust wave planning dynamically 4. Alert on emerging conflicts ``` ### 3. Post-Execution Learning ```markdown After completion: 1. Compare predicted vs actual conflicts 2. Update analysis patterns 3. Refine risk assessment models 4. Improve future predictions ``` ## Platform Adaptation ### OpenAI/GPT ```javascript const response = await openai.chat.completions.create({ model: "gpt-4", messages: [ { role: "system", content: analysisPrompt, }, ], response_format: { type: "json_object" }, }); ``` ### Anthropic/Claude ```javascript const response = await anthropic.messages.create({ model: "claude-3-opus-20240229", messages: [ { role: "user", content: analysisPrompt, }, ], }); ``` ### Google/Gemini ```javascript const response = await model.generateContent({ contents: [ { parts: [ { text: analysisPrompt, }, ], }, ], }); ``` ## Benefits Over Script-Based Analysis 1. **Deeper Understanding**: Comprehends code purpose, not just file names 2. **Flexible Detection**: Finds non-obvious dependencies 3. **Risk-Based Planning**: Prioritizes based on actual impact 4. **Platform Agnostic**: Works with any LLM provider 5. **Continuous Learning**: Improves with feedback 6. **Context Aware**: Understands architectural patterns ## Usage Example ```bash # Analyze dependencies for sprint work llm-analyze-dependencies \ --work-items "story-1.md,story-2.md,story-3.md" \ --architecture "microservices" \ --output "dependency-analysis.json" # Generate execution plan llm-plan-parallel \ --dependency-analysis "dependency-analysis.json" \ --max-parallel 4 \ --risk-tolerance "medium" \ --output "execution-plan.json" ``` This LLM-native approach provides intelligent, semantic analysis that goes far beyond simple file matching, enabling truly smart parallel development planning.