mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-15 02:42:45 +08:00
- Phase 3: Added Mermaid diagram generation for system architecture, function modules, algorithms, class diagrams, sequence diagrams, and error flows. - Phase 4: Assembled analysis and diagrams into a structured CPCC-compliant document with section templates and figure numbering. - Phase 5: Developed compliance review process with iterative refinement based on analysis findings and user feedback. - Added CPCC compliance requirements and quality standards for project analysis reports. - Established a comprehensive project analysis skill with detailed execution flow and report types. - Enhanced error handling and recovery mechanisms throughout the analysis phases.
87 lines
2.7 KiB
Markdown
87 lines
2.7 KiB
Markdown
# Phase 3.5: Diagram Generation
|
|
|
|
Generate Mermaid diagrams based on report type and analysis data.
|
|
|
|
> **Reference**: See [mermaid-utils.md](../../_shared/mermaid-utils.md) for utility functions.
|
|
|
|
## Execution
|
|
|
|
### Step 1: Determine Required Diagrams
|
|
|
|
```javascript
|
|
const diagramRequirements = {
|
|
architecture: [
|
|
{type: 'architecture', format: 'graph TD', file: 'architecture.mmd'},
|
|
{type: 'layers', format: 'graph TD', file: 'layers.mmd'},
|
|
{type: 'dependencies', format: 'graph LR', file: 'dependencies.mmd'},
|
|
{type: 'dataflow', format: 'flowchart LR', file: 'dataflow.mmd'}
|
|
],
|
|
design: [
|
|
{type: 'class', format: 'classDiagram', file: 'class-diagram.mmd'},
|
|
{type: 'components', format: 'graph TD', file: 'components.mmd'},
|
|
{type: 'patterns', format: 'graph TD', file: 'patterns.mmd'},
|
|
{type: 'state', format: 'stateDiagram-v2', file: 'state.mmd'}
|
|
],
|
|
methods: [
|
|
{type: 'algorithm', format: 'flowchart TD', file: 'algorithm-*.mmd'},
|
|
{type: 'sequence', format: 'sequenceDiagram', file: 'sequence-*.mmd'},
|
|
{type: 'critical_path', format: 'flowchart LR', file: 'critical-path.mmd'},
|
|
{type: 'api', format: 'graph LR', file: 'api.mmd'}
|
|
],
|
|
comprehensive: [
|
|
{type: 'architecture', format: 'graph TD', file: 'architecture.mmd'},
|
|
{type: 'class', format: 'classDiagram', file: 'class-diagram.mmd'},
|
|
{type: 'sequence', format: 'sequenceDiagram', file: 'sequence-main.mmd'},
|
|
{type: 'dataflow', format: 'flowchart LR', file: 'dataflow.mmd'}
|
|
]
|
|
};
|
|
|
|
const required = diagramRequirements[config.type];
|
|
```
|
|
|
|
### Step 2: Generate Each Diagram
|
|
|
|
Use shared utilities from `../_shared/mermaid-utils.md`:
|
|
|
|
```javascript
|
|
// Import utilities
|
|
const { sanitizeId, escapeLabel, generateClassDiagram, generateSequenceDiagram, validateMermaidSyntax } = require('../_shared/mermaid-utils.md');
|
|
|
|
for (const diagram of required) {
|
|
const content = generateDiagram(diagram.type, diagram.format, analysisData);
|
|
Write(`${outputDir}/diagrams/${diagram.file}`, content);
|
|
}
|
|
```
|
|
|
|
### Step 3: Validate All Diagrams
|
|
|
|
```javascript
|
|
const validationResults = validateDiagramDirectory(`${outputDir}/diagrams`);
|
|
const failedDiagrams = validationResults.filter(r => !r.valid);
|
|
|
|
if (failedDiagrams.length > 0) {
|
|
// Regenerate failed diagrams
|
|
for (const failed of failedDiagrams) {
|
|
regenerateDiagram(failed.file, failed.issues);
|
|
}
|
|
}
|
|
```
|
|
|
|
### Step 4: Create Diagram Manifest
|
|
|
|
```javascript
|
|
Write(`${outputDir}/diagrams/manifest.json`, JSON.stringify({
|
|
generated_at: new Date().toISOString(),
|
|
diagrams: required.map(d => ({
|
|
type: d.type,
|
|
file: d.file,
|
|
format: d.format
|
|
})),
|
|
validation: validationResults
|
|
}, null, 2));
|
|
```
|
|
|
|
## Output
|
|
|
|
Save diagrams to `diagrams/` folder with `manifest.json`.
|