feat: add Mermaid output to diff-impact#58
Conversation
The existing check only matched direct pushes with 'chore: release v' commit messages. Merged PRs have 'Merge pull request ... from release/vX' as the commit message, bypassing the guard and triggering an unwanted dev publish.
Add --format mermaid flag to diff-impact for generating ready-to-use Mermaid flowcharts showing changed functions, transitive callers, and blast radius in a single command. - Enhance diffImpactData BFS to return depth-structured levels, edges, and newFiles detection (backward-compatible additions) - Add diffImpactMermaid function that builds flowchart TB diagrams with color-coded subgraphs (green=new, orange=modified, purple=blast radius) - Add --format option to CLI diff-impact command (text/mermaid/json) - Add format property to MCP diff_impact tool schema - Export diffImpactMermaid from index.js - Add unit tests for levels/edges, new file detection, and Mermaid output - Update llm-integration.md with PR impact graph roadmap Impact: 6 functions changed, 5 affected
Impact Graphflowchart TB
subgraph sg0["src/cli.js **(modified)**"]
n0["command:diff-impact"]
n1["command:export"]
n2["command:cycles"]
n3["command:models"]
n4["command:structure"]
end
style sg0 fill:#fff3e0,stroke:#ff9800
subgraph sg1["src/cycles.js **(modified)**"]
n5["findCycles"]
end
style sg1 fill:#fff3e0,stroke:#ff9800
subgraph sg2["src/export.js **(modified)**"]
n11["exportDOT"]
n12["exportMermaid"]
n13["exportJSON"]
end
style sg2 fill:#fff3e0,stroke:#ff9800
subgraph sg3["src/mcp.js **(modified)**"]
n6["startMCPServer"]
end
style sg3 fill:#fff3e0,stroke:#ff9800
subgraph sg4["src/queries.js **(modified)**"]
n14["isTestFile"]
n21["diffImpactData"]
n32["diffImpactMermaid"]
n44["nodeId"]
n7["statsData"]
n33["diffImpact"]
end
style sg4 fill:#fff3e0,stroke:#ff9800
subgraph sg5["src/structure.js **(modified)**"]
n45["structureData"]
end
style sg5 fill:#fff3e0,stroke:#ff9800
n9["stats"]
n15["findMatchingNodes"]
n16["queryNameData"]
n17["impactAnalysisData"]
n18["fileDepsData"]
n19["fnDepsData"]
n20["fnImpactData"]
n23["getFileLines"]
n24["explainFunctionImpl"]
n25["whereSymbolImpl"]
n26["contextData"]
n27["queryName"]
n28["impactAnalysis"]
n29["fileDeps"]
n30["fnDeps"]
n31["fnImpact"]
n36["whereData"]
subgraph sg6["Callers **(blast radius)**"]
n8["command:mcp"]
n10["command:stats"]
n22["listFunctionsData"]
n34["explainFileImpl"]
n35["getFileLines"]
n37["context"]
n38["command:query"]
n39["command:impact"]
n40["command:deps"]
n41["command:fn"]
n42["command:fn-impact"]
n43["where"]
end
style sg6 fill:#f3e5f5,stroke:#9c27b0
n5 --> n2
n5 --> n6
n5 --> n7
n6 --> n8
n7 --> n9
n9 --> n10
n11 --> n1
n11 --> n6
n12 --> n1
n12 --> n6
n13 --> n1
n13 --> n6
n14 --> n15
n14 --> n16
n14 --> n17
n14 --> n18
n14 --> n19
n14 --> n20
n14 --> n21
n14 --> n22
n14 --> n7
n14 --> n23
n14 --> n24
n14 --> n25
n15 --> n26
n16 --> n6
n16 --> n27
n17 --> n28
n18 --> n29
n19 --> n30
n20 --> n31
n21 --> n32
n21 --> n33
n23 --> n34
n24 --> n35
n25 --> n36
n26 --> n37
n27 --> n38
n28 --> n39
n29 --> n40
n30 --> n41
n31 --> n42
n33 --> n0
n36 --> n43
n21 --> n6
n32 --> n6
n32 --> n33
n45 --> n4
n45 --> n6
|
|
Claude finished @carlos-alm's task —— View job PR Review AnalysisReviewing PR: feat: add Mermaid output to diff-impact Review Checklist
Phase 1: Root Cause Analysis ✅Problem Being Solved: The PR adds visual Mermaid flowchart output to the existing Why This Approach: The implementation builds upon existing Risk Assessment: LOW - This is additive functionality that doesn't modify existing behavior. Phase 2: Configuration Change Detection ✅Findings: ✅ NO HIGH-RISK CONFIGURATION CHANGES DETECTED
The only workflow change is a minor publish.yml fix (npm token → NPM_TOKEN variable) which appears unrelated to this PR's functionality. Phase 3: Test Integrity Assessment ✅Test Quality: ✅ TESTS ARE COMPREHENSIVE AND ROBUST New test coverage in
Test Integrity: No existing tests were modified or weakened. All assertions remain strict. Phase 4: Code Quality Review ✅Implementation Quality: EXCELLENT
Enhanced
CLI Integration (
MCP Integration (
Security: ✅ NO SECURITY CONCERNS
Performance: ✅ EFFICIENT
Minor Observations:
Root Cause AnalysisProblem Being Solved: Adding visual impact analysis for code changes via Mermaid flowcharts - a legitimate developer productivity enhancement. Why This Approach: Extends existing Risk Assessment: LOW RISK - Additive feature with comprehensive test coverage and no breaking changes. Critical ConcernsNone identified. This is a high-quality implementation with proper testing. Final Recommendation
|
Greptile SummaryAdded Mermaid flowchart output format to Key changes:
All changes are well-tested and backward-compatible. Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI: codegraph diff-impact --format mermaid] --> B[queries.js: diffImpact]
B --> C{Format Check}
C -->|format=mermaid| D[diffImpactMermaid]
C -->|format=json| E[diffImpactData + JSON output]
C -->|format=text| F[diffImpactData + text output]
D --> G[diffImpactData]
E --> G
F --> G
G --> H[Parse git diff output]
H --> I[Detect new files via /dev/null]
H --> J[Track changed line ranges]
J --> K[Find affected functions]
K --> L[BFS: Build levels & edges]
L --> M{Return to caller}
M -->|diffImpactMermaid| N[Generate Mermaid flowchart]
M -->|diffImpactData| O[Return structured data]
N --> P[Group by file subgraphs]
P --> Q[Detect blast radius nodes]
Q --> R[Apply color styling]
R --> S[Return Mermaid string]
T[MCP: diff_impact tool] --> U{format param}
U -->|format=mermaid| D
U -->|format=json| E
style D fill:#e8f5e9,stroke:#4caf50
style N fill:#e8f5e9,stroke:#4caf50
style G fill:#fff3e0,stroke:#ff9800
style L fill:#fff3e0,stroke:#ff9800
Last reviewed commit: d2d767f |
Restructure README to follow: problem → value → quick start → reference. Open with the real pain (AI agents burning tokens re-orienting in large codebases), then what codegraph does about it, then how easy it is to start. Move competitive comparison to a condensed table at the bottom. Remove defensive Narsil head-to-head section. Add --format mermaid diff-impact example from PR #58.
Restructure README to follow: problem → value → quick start → reference. Open with the real pain (AI agents burning tokens re-orienting in large codebases), then what codegraph does about it, then how easy it is to start. Move competitive comparison to a condensed table at the bottom. Remove defensive Narsil head-to-head section. Add --format mermaid diff-impact example from PR #58.
Summary
--format mermaidflag todiff-impactfor generating ready-to-use Mermaid flowcharts showing changed functions, transitive callers, and blast radiusdiffImpactDataBFS to return depth-structuredlevels,edges, andnewFiles(backward-compatible)formatproperty to MCPdiff_impacttool schemadocs/llm-integration.mdwith PR impact graph roadmapUsage
Test plan
levels/edgesindiffImpactData, new file detection, anddiffImpactMermaidoutput--format text,--format json,--format mermaid,--staged