\split analyze workflow

This commit is contained in:
Brian Madison
2025-10-12 01:39:24 -05:00
parent 2b736a8594
commit ab05cdcdd2
303 changed files with 41999 additions and 1495 deletions

View File

@@ -10,22 +10,336 @@
{{target_description}}
**Purpose:** {{target_purpose}}
**Key Responsibilities:** {{responsibilities}}
**Integration Points:** {{integration_summary}}
## Complete File Inventory
{{#each files_in_inventory}}
### {{file_path}}
**Purpose:** {{purpose}}
**Lines of Code:** {{loc}}
**File Type:** {{file_type}}
**What Future Contributors Must Know:** {{contributor_note}}
**Exports:**
{{#each exports}}
- `{{signature}}` - {{description}}
{{/each}}
**Dependencies:**
{{#each imports}}
- `{{import_path}}` - {{reason}}
{{/each}}
**Used By:**
{{#each dependents}}
- `{{dependent_path}}`
{{/each}}
**Key Implementation Details:**
```{{language}}
{{key_code_snippet}}
```
{{implementation_notes}}
**Patterns Used:**
{{#each patterns}}
- {{pattern_name}}: {{pattern_description}}
{{/each}}
**State Management:** {{state_approach}}
**Side Effects:**
{{#each side_effects}}
- {{effect_type}}: {{effect_description}}
{{/each}}
**Error Handling:** {{error_handling_approach}}
**Testing:**
- Test File: {{test_file_path}}
- Coverage: {{coverage_percentage}}%
- Test Approach: {{test_approach}}
**Comments/TODOs:**
{{#each todos}}
- Line {{line_number}}: {{todo_text}}
{{/each}}
---
**Note:** The deep-dive documentation structure is defined inline in Step 13e of instructions.md.
This template file serves as a reference and placeholder for the deep-dive generation process.
{{/each}}
The actual documentation includes:
## Contributor Checklist
- Complete file inventory with all exports and signatures
- Dependency graphs and data flow analysis
- Integration points and API contracts
- Testing coverage and strategies
- Related code and reuse opportunities
- Implementation guidance and modification notes
- **Risks & Gotchas:** {{risks_notes}}
- **Pre-change Verification Steps:** {{verification_steps}}
- **Suggested Tests Before PR:** {{suggested_tests}}
See Step 13e in instructions.md for the complete template structure.
## Architecture & Design Patterns
### Code Organization
{{organization_approach}}
### Design Patterns
{{#each design_patterns}}
- **{{pattern_name}}**: {{usage_description}}
{{/each}}
### State Management Strategy
{{state_management_details}}
### Error Handling Philosophy
{{error_handling_philosophy}}
### Testing Strategy
{{testing_strategy}}
## Data Flow
{{data_flow_diagram}}
### Data Entry Points
{{#each entry_points}}
- **{{entry_name}}**: {{entry_description}}
{{/each}}
### Data Transformations
{{#each transformations}}
- **{{transformation_name}}**: {{transformation_description}}
{{/each}}
### Data Exit Points
{{#each exit_points}}
- **{{exit_name}}**: {{exit_description}}
{{/each}}
## Integration Points
### APIs Consumed
{{#each apis_consumed}}
- **{{api_endpoint}}**: {{api_description}}
- Method: {{method}}
- Authentication: {{auth_requirement}}
- Response: {{response_schema}}
{{/each}}
### APIs Exposed
{{#each apis_exposed}}
- **{{api_endpoint}}**: {{api_description}}
- Method: {{method}}
- Request: {{request_schema}}
- Response: {{response_schema}}
{{/each}}
### Shared State
{{#each shared_state}}
- **{{state_name}}**: {{state_description}}
- Type: {{state_type}}
- Accessed By: {{accessors}}
{{/each}}
### Events
{{#each events}}
- **{{event_name}}**: {{event_description}}
- Type: {{publish_or_subscribe}}
- Payload: {{payload_schema}}
{{/each}}
### Database Access
{{#each database_operations}}
- **{{table_name}}**: {{operation_type}}
- Queries: {{query_patterns}}
- Indexes Used: {{indexes}}
{{/each}}
## Dependency Graph
{{dependency_graph_visualization}}
### Entry Points (Not Imported by Others in Scope)
{{#each entry_point_files}}
- {{file_path}}
{{/each}}
### Leaf Nodes (Don't Import Others in Scope)
{{#each leaf_files}}
- {{file_path}}
{{/each}}
### Circular Dependencies
{{#if has_circular_dependencies}}
⚠️ Circular dependencies detected:
{{#each circular_deps}}
- {{cycle_description}}
{{/each}}
{{else}}
✓ No circular dependencies detected
{{/if}}
## Testing Analysis
### Test Coverage Summary
- **Statements:** {{statements_coverage}}%
- **Branches:** {{branches_coverage}}%
- **Functions:** {{functions_coverage}}%
- **Lines:** {{lines_coverage}}%
### Test Files
{{#each test_files}}
- **{{test_file_path}}**
- Tests: {{test_count}}
- Approach: {{test_approach}}
- Mocking Strategy: {{mocking_strategy}}
{{/each}}
### Test Utilities Available
{{#each test_utilities}}
- `{{utility_name}}`: {{utility_description}}
{{/each}}
### Testing Gaps
{{#each testing_gaps}}
- {{gap_description}}
{{/each}}
## Related Code & Reuse Opportunities
### Similar Features Elsewhere
{{#each similar_features}}
- **{{feature_name}}** (`{{feature_path}}`)
- Similarity: {{similarity_description}}
- Can Reference For: {{reference_use_case}}
{{/each}}
### Reusable Utilities Available
{{#each reusable_utilities}}
- **{{utility_name}}** (`{{utility_path}}`)
- Purpose: {{utility_purpose}}
- How to Use: {{usage_example}}
{{/each}}
### Patterns to Follow
{{#each patterns_to_follow}}
- **{{pattern_name}}**: Reference `{{reference_file}}` for implementation
{{/each}}
## Implementation Notes
### Code Quality Observations
{{#each quality_observations}}
- {{observation}}
{{/each}}
### TODOs and Future Work
{{#each all_todos}}
- **{{file_path}}:{{line_number}}**: {{todo_text}}
{{/each}}
### Known Issues
{{#each known_issues}}
- {{issue_description}}
{{/each}}
### Optimization Opportunities
{{#each optimizations}}
- {{optimization_suggestion}}
{{/each}}
### Technical Debt
{{#each tech_debt_items}}
- {{debt_description}}
{{/each}}
## Modification Guidance
### To Add New Functionality
{{modification_guidance_add}}
### To Modify Existing Functionality
{{modification_guidance_modify}}
### To Remove/Deprecate
{{modification_guidance_remove}}
### Testing Checklist for Changes
{{#each testing_checklist_items}}
- [ ] {{checklist_item}}
{{/each}}
---
_Generated by `document-project` workflow (deep-dive mode)_
_Base Documentation: docs/index.md_
_Scan Date: {{date}}_
_Analysis Mode: Exhaustive_

View File

@@ -0,0 +1,298 @@
# Deep-Dive Documentation Instructions
<workflow>
<critical>This workflow performs exhaustive deep-dive documentation of specific areas</critical>
<critical>Called by: ../document-project/instructions.md router</critical>
<critical>Handles: deep_dive mode only</critical>
<step n="13" goal="Deep-dive documentation of specific area" if="workflow_mode == deep_dive">
<critical>Deep-dive mode requires literal full-file review. Sampling, guessing, or relying solely on tooling output is FORBIDDEN.</critical>
<action>Load existing project structure from index.md and project-parts.json (if exists)</action>
<action>Load source tree analysis to understand available areas</action>
<step n="13a" goal="Identify area for deep-dive">
<action>Analyze existing documentation to suggest deep-dive options</action>
<ask>What area would you like to deep-dive into?
**Suggested Areas Based on Project Structure:**
{{#if has_api_routes}}
### API Routes ({{api_route_count}} endpoints found)
{{#each api_route_groups}}
{{group_index}}. {{group_name}} - {{endpoint_count}} endpoints in `{{path}}`
{{/each}}
{{/if}}
{{#if has_feature_modules}}
### Feature Modules ({{feature_count}} features)
{{#each feature_modules}}
{{module_index}}. {{module_name}} - {{file_count}} files in `{{path}}`
{{/each}}
{{/if}}
{{#if has_ui_components}}
### UI Component Areas
{{#each component_groups}}
{{group_index}}. {{group_name}} - {{component_count}} components in `{{path}}`
{{/each}}
{{/if}}
{{#if has_services}}
### Services/Business Logic
{{#each service_groups}}
{{service_index}}. {{service_name}} - `{{path}}`
{{/each}}
{{/if}}
**Or specify custom:**
- Folder path (e.g., "client/src/features/dashboard")
- File path (e.g., "server/src/api/users.ts")
- Feature name (e.g., "authentication system")
Enter your choice (number or custom path):
</ask>
<action>Parse user input to determine: - target_type: "folder" | "file" | "feature" | "api_group" | "component_group" - target_path: Absolute path to scan - target_name: Human-readable name for documentation - target_scope: List of all files to analyze
</action>
<action>Store as {{deep_dive_target}}</action>
<action>Display confirmation:
Target: {{target_name}}
Type: {{target_type}}
Path: {{target_path}}
Estimated files to analyze: {{estimated_file_count}}
This will read EVERY file in this area. Proceed? [y/n]
</action>
<action if="user confirms 'n'">Return to Step 13a (select different area)</action>
</step>
<step n="13b" goal="Comprehensive exhaustive scan of target area">
<action>Set scan_mode = "exhaustive"</action>
<action>Initialize file_inventory = []</action>
<critical>You must read every line of every file in scope and capture a plain-language explanation (what the file does, side effects, why it matters) that future developer agents can act on. No shortcuts.</critical>
<check if="target_type == folder">
<action>Get complete recursive file list from {{target_path}}</action>
<action>Filter out: node_modules/, .git/, dist/, build/, coverage/, *.min.js, *.map</action>
<action>For EVERY remaining file in folder:
- Read complete file contents (all lines)
- Extract all exports (functions, classes, types, interfaces, constants)
- Extract all imports (dependencies)
- Identify purpose from comments and code structure
- Write 1-2 sentences (minimum) in natural language describing behaviour, side effects, assumptions, and anything a developer must know before modifying the file
- Extract function signatures with parameter types and return types
- Note any TODOs, FIXMEs, or comments
- Identify patterns (hooks, components, services, controllers, etc.)
- Capture per-file contributor guidance: `contributor_note`, `risks`, `verification_steps`, `suggested_tests`
- Store in file_inventory
</action>
</check>
<check if="target_type == file">
<action>Read complete file at {{target_path}}</action>
<action>Extract all information as above</action>
<action>Read all files it imports (follow import chain 1 level deep)</action>
<action>Find all files that import this file (dependents via grep)</action>
<action>Store all in file_inventory</action>
</check>
<check if="target_type == api_group">
<action>Identify all route/controller files in API group</action>
<action>Read all route handlers completely</action>
<action>Read associated middleware, controllers, services</action>
<action>Read data models and schemas used</action>
<action>Extract complete request/response schemas</action>
<action>Document authentication and authorization requirements</action>
<action>Store all in file_inventory</action>
</check>
<check if="target_type == feature">
<action>Search codebase for all files related to feature name</action>
<action>Include: UI components, API endpoints, models, services, tests</action>
<action>Read each file completely</action>
<action>Store all in file_inventory</action>
</check>
<check if="target_type == component_group">
<action>Get all component files in group</action>
<action>Read each component completely</action>
<action>Extract: Props interfaces, hooks used, child components, state management</action>
<action>Store all in file_inventory</action>
</check>
<action>For each file in file\*inventory, document: - **File Path:** Full path - **Purpose:** What this file does (1-2 sentences) - **Lines of Code:** Total LOC - **Exports:** Complete list with signatures
- Functions: `functionName(param: Type): ReturnType` - Description
_ Classes: `ClassName` - Description with key methods
_ Types/Interfaces: `TypeName` - Description
\_ Constants: `CONSTANT_NAME: Type` - Description - **Imports/Dependencies:** What it uses and why - **Used By:** Files that import this (dependents) - **Key Implementation Details:** Important logic, algorithms, patterns - **State Management:** If applicable (Redux, Context, local state) - **Side Effects:** API calls, database queries, file I/O, external services - **Error Handling:** Try/catch blocks, error boundaries, validation - **Testing:** Associated test files and coverage - **Comments/TODOs:** Any inline documentation or planned work
</action>
<template-output>comprehensive_file_inventory</template-output>
</step>
<step n="13c" goal="Analyze relationships and data flow">
<action>Build dependency graph for scanned area:
- Create graph with files as nodes
- Add edges for import relationships
- Identify circular dependencies if any
- Find entry points (files not imported by others in scope)
- Find leaf nodes (files that don't import others in scope)
</action>
<action>Trace data flow through the system: - Follow function calls and data transformations - Track API calls and their responses - Document state updates and propagation - Map database queries and mutations
</action>
<action>Identify integration points: - External APIs consumed - Internal APIs/services called - Shared state accessed - Events published/subscribed - Database tables accessed
</action>
<template-output>dependency_graph</template-output>
<template-output>data_flow_analysis</template-output>
<template-output>integration_points</template-output>
</step>
<step n="13d" goal="Find related code and similar patterns">
<action>Search codebase OUTSIDE scanned area for:
- Similar file/folder naming patterns
- Similar function signatures
- Similar component structures
- Similar API patterns
- Reusable utilities that could be used
</action>
<action>Identify code reuse opportunities: - Shared utilities available - Design patterns used elsewhere - Component libraries available - Helper functions that could apply
</action>
<action>Find reference implementations: - Similar features in other parts of codebase - Established patterns to follow - Testing approaches used elsewhere
</action>
<template-output>related_code_references</template-output>
<template-output>reuse_opportunities</template-output>
</step>
<step n="13e" goal="Generate comprehensive deep-dive documentation">
<action>Create documentation filename: deep-dive-{{sanitized_target_name}}.md</action>
<action>Aggregate contributor insights across files:
- Combine unique risk/gotcha notes into {{risks_notes}}
- Combine verification steps developers should run before changes into {{verification_steps}}
- Combine recommended test commands into {{suggested_tests}}
</action>
<action>Load complete deep-dive template from: {installed_path}/templates/deep-dive-template.md</action>
<action>Fill template with all collected data from steps 13b-13d</action>
<action>Write filled template to: {output_folder}/deep-dive-{{sanitized_target_name}}.md</action>
<action>Validate deep-dive document completeness</action>
<template-output>deep_dive_documentation</template-output>
<action>Update state file: - Add to deep_dive_targets array: {"target_name": "{{target_name}}", "target_path": "{{target_path}}", "files_analyzed": {{file_count}}, "output_file": "deep-dive-{{sanitized_target_name}}.md", "timestamp": "{{now}}"} - Add output to outputs_generated - Update last_updated timestamp
</action>
</step>
<step n="13f" goal="Update master index with deep-dive link">
<action>Read existing index.md</action>
<action>Check if "Deep-Dive Documentation" section exists</action>
<check if="section does not exist">
<action>Add new section after "Generated Documentation":
## Deep-Dive Documentation
Detailed exhaustive analysis of specific areas:
</action>
</check>
<action>Add link to new deep-dive doc:
- [{{target_name}} Deep-Dive](./deep-dive-{{sanitized_target_name}}.md) - Comprehensive analysis of {{target_description}} ({{file_count}} files, {{total_loc}} LOC) - Generated {{date}}
</action>
<action>Update index metadata:
Last Updated: {{date}}
Deep-Dives: {{deep_dive_count}}
</action>
<action>Save updated index.md</action>
<template-output>updated_index</template-output>
</step>
<step n="13g" goal="Offer to continue or complete">
<action>Display summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
## Deep-Dive Documentation Complete! ✓
**Generated:** {output_folder}/deep-dive-{{target_name}}.md
**Files Analyzed:** {{file_count}}
**Lines of Code Scanned:** {{total_loc}}
**Time Taken:** ~{{duration}}
**Documentation Includes:**
- Complete file inventory with all exports
- Dependency graph and data flow
- Integration points and API contracts
- Testing analysis and coverage
- Related code and reuse opportunities
- Implementation guidance
**Index Updated:** {output_folder}/index.md now includes link to this deep-dive
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
</action>
<ask>Would you like to:
1. **Deep-dive another area** - Analyze another feature/module/folder
2. **Finish** - Complete workflow
Your choice [1/2]:
</ask>
<action if="user selects 1">
<action>Clear current deep_dive_target</action>
<action>Go to Step 13a (select new area)</action>
</action>
<action if="user selects 2">
<action>Display final message:
All deep-dive documentation complete!
**Master Index:** {output_folder}/index.md
**Deep-Dives Generated:** {{deep_dive_count}}
These comprehensive docs are now ready for:
- Architecture review
- Implementation planning
- Code understanding
- Brownfield PRD creation
Thank you for using the document-project workflow!
</action>
<action>Exit workflow</action>
</action>
</step>
</step>
</workflow>

View File

@@ -0,0 +1,31 @@
# Deep-Dive Documentation Workflow Configuration
name: "document-project-deep-dive"
description: "Exhaustive deep-dive documentation of specific project areas"
author: "BMad"
# This is a sub-workflow called by document-project/workflow.yaml
parent_workflow: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/workflow.yaml"
# Critical variables inherited from parent
config_source: "{project-root}/bmad/bmb/config.yaml"
output_folder: "{config_source}:output_folder"
user_name: "{config_source}:user_name"
date: system-generated
# Module path and component files
installed_path: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/workflows"
template: false # Action workflow
instructions: "{installed_path}/deep-dive-instructions.md"
validation: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/checklist.md"
# Templates
deep_dive_template: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/templates/deep-dive-template.md"
# Runtime inputs (passed from parent workflow)
workflow_mode: "deep_dive"
scan_level: "exhaustive" # Deep-dive always uses exhaustive scan
project_root_path: ""
existing_index_path: "" # Path to existing index.md
# Configuration
autonomous: false # Requires user input to select target area

View File

@@ -0,0 +1,33 @@
# Full Project Scan Workflow Configuration
name: "document-project-full-scan"
description: "Complete project documentation workflow (initial scan or full rescan)"
author: "BMad"
# This is a sub-workflow called by document-project/workflow.yaml
parent_workflow: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/workflow.yaml"
# Critical variables inherited from parent
config_source: "{project-root}/bmad/bmb/config.yaml"
output_folder: "{config_source}:output_folder"
user_name: "{config_source}:user_name"
date: system-generated
# Data files
project_types_csv: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/data/project-types.csv"
documentation_requirements_csv: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/data/documentation-requirements.csv"
architecture_registry_csv: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/data/architecture-registry.csv"
# Module path and component files
installed_path: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/workflows"
template: false # Action workflow
instructions: "{installed_path}/full-scan-instructions.md"
validation: "{project-root}/src/modules/bmm/workflows/1-analysis/document-project/checklist.md"
# Runtime inputs (passed from parent workflow)
workflow_mode: "" # "initial_scan" or "full_rescan"
scan_level: "" # "quick", "deep", or "exhaustive"
resume_mode: false
project_root_path: ""
# Configuration
autonomous: false # Requires user input at key decision points