depgraph-core 1.0.3 β†’ 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,25 +1,52 @@
1
- # πŸ“Š DepGraph Core
1
+ # DepGraph Core
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/depgraph-core.svg)](https://www.npmjs.com/package/depgraph-core)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- **DepGraph Core** is a powerful static analysis CLI that maps code dependencies and simulates the ripple-effect impact of changes in JavaScript, TypeScript, Python, and Go projects. By parsing imports, exports, functions, and classes, DepGraph constructs a comprehensive dependency graph, computes centrality metrics, and generates impact simulations β€” helping you prevent regression bugs in large codebases.
6
+ **DepGraph Core** is a powerful static analysis CLI that maps code dependencies and simulates the ripple-effect impact of changes across multi-language codebases β€” supporting JavaScript, TypeScript, Python, Go, C#, Java, Kotlin, PHP, Ruby, and Swift. By parsing imports, exports, functions, classes, interfaces, and methods, DepGraph constructs a comprehensive dependency graph, computes centrality metrics, and generates impact simulations β€” helping you prevent regression bugs in large systems.
7
7
 
8
8
  ---
9
9
 
10
- ## πŸš€ Key Features
10
+ ## Key Features
11
+
12
+ - **Multi-Language AST & Regex Code Parsing**: Comprehensive native extractors for **10 languages**:
13
+ - **JavaScript / TypeScript / React** (`.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs`)
14
+ - **Python** (`.py`)
15
+ - **Go** (`.go`)
16
+ - **C#** (`.cs`)
17
+ - **Java** (`.java`)
18
+ - **Kotlin** (`.kt`, `.kts`)
19
+ - **PHP** (`.php`)
20
+ - **Ruby** (`.rb`)
21
+ - **Swift** (`.swift`)
22
+ - **Dependency Graph Reconstruction**: Resolves local imports, aliases, namespace packages, and cross-file relationships to build a full topology map of your codebase.
23
+ - **Metrics & Centrality Analysis**: Calculates in-degree, out-degree, and centrality scores for every entity to automatically identify **Critical Nodes**.
24
+ - **Impact Simulation Engine**: Runs a reverse BFS to model the cascading impact of changing a specific function or class. Generates a risk score, lists affected nodes, and provides an actionable testing plan.
25
+ - **Git Diff Integration**: Automatically detects changed entities from your git history (uncommitted changes, a specific commit, or a branch comparison) across all supported languages and runs impact simulation on every changed symbol.
26
+ - **Rich CLI Interface**: Colorized, human-readable output with a `--no-color` flag for CI/CD pipelines.
27
+ - **Detailed JSON Output**: Exports a comprehensive report containing graph structure, metrics, and simulation results.
11
28
 
12
- - πŸ” **Automated Code Parsing**: Supports JS, TS, React (`.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs`), Python (`.py`), and Go (`.go`) β€” extracting functions, classes, interfaces, types, React hooks/components, and Express routes.
13
- - πŸ•ΈοΈ **Dependency Graph Reconstruction**: Resolves local imports and links entities across files to build a full topology map of your codebase.
14
- - πŸ“ˆ **Metrics & Centrality Analysis**: Calculates in-degree, out-degree, and centrality scores for every entity to automatically identify **Critical Nodes**.
15
- - πŸ’₯ **Impact Simulation Engine**: Runs a reverse BFS to model the cascading impact of changing a specific function or class. Generates a risk score, lists affected nodes, and provides an actionable testing plan.
16
- - 🧬 **Git Diff Integration**: Automatically detects changed entities from your git history (uncommitted changes, a specific commit, or a branch comparison) and runs impact simulation on every changed function β€” no manual target needed.
17
- - πŸ–₯️ **Rich CLI Interface**: Colorized, human-readable output with a `--no-color` flag for CI/CD pipelines.
18
- - πŸ’Ύ **Detailed JSON Output**: Exports a comprehensive report containing graph structure, metrics, and simulation results.
29
+ ---
30
+
31
+ ## Supported Languages
32
+
33
+ DepGraph Core provides native parsing and symbol extraction across 10 major programming languages:
34
+
35
+ | Language | Extensions | Extracted Entities | Import & Resolution Features |
36
+ | :--- | :--- | :--- | :--- |
37
+ | **JavaScript / TypeScript** | `.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs` | Functions, Async functions, Classes, Methods, Interfaces, Type aliases, React Components, Hooks, Express routes | ESM (`import`/`export`), dynamic `import()`, CommonJS (`require()`, `module.exports`), named & default imports |
38
+ | **Python** | `.py` | Functions, Async functions, Classes, Methods | `import x`, `from x import y`, aliases (`as`), wildcard imports (`*`), `__all__` exports |
39
+ | **Go** | `.go` | Functions, Struct methods (pointer & value receivers), Structs, Interfaces | Single & grouped `import (...)`, import aliases, exported symbols (capitalized identifier convention) |
40
+ | **C#** | `.cs` | Classes, Records, Interfaces, Structs, Enums, Methods, Namespaces | Single & global `using`, static imports (`using static`), using aliases, public/internal exports |
41
+ | **Java** | `.java` | Classes, Interfaces, Records, Enums, Methods, Constructors | Single imports, wildcard imports (`.*`), static imports (`import static`), package tracking, public/protected exports |
42
+ | **Kotlin** | `.kt`, `.kts` | Classes (data, sealed, abstract, inner), Objects, Companion objects, Interfaces, Functions, Suspend functions | Direct imports, wildcard imports (`.*`), import aliases (`as`), packages |
43
+ | **PHP** | `.php` | Classes (abstract, final), Interfaces, Traits, Enums, Functions, Methods | Namespaces, single & grouped `use` statements, `use ... as` aliases, `require`/`include` file paths |
44
+ | **Ruby** | `.rb` | Classes, Modules, Instance methods, Class methods (`def self.`), `attr_accessor`/`reader`/`writer` | `require`, `require_relative`, `load`, `include`, `extend`, `prepend` |
45
+ | **Swift** | `.swift` | Classes, Structs, Enums, Protocols, Actors, Extensions (including `where` constraints), Functions, Initializers | Module imports, sub-module imports, kind-specifier imports (`import class/func/...`) |
19
46
 
20
47
  ---
21
48
 
22
- ## πŸ“¦ Installation
49
+ ## Installation
23
50
 
24
51
  ### Global (recommended)
25
52
  ```bash
@@ -33,7 +60,7 @@ npx depgraph-core <projectDir> [options]
33
60
 
34
61
  ---
35
62
 
36
- ## πŸ› οΈ CLI Usage
63
+ ## CLI Usage
37
64
 
38
65
  ```bash
39
66
  depgraph <projectDir> [options]
@@ -60,7 +87,7 @@ depgraph <projectDir> [options]
60
87
 
61
88
  ---
62
89
 
63
- ## πŸ“– Examples
90
+ ## Examples
64
91
 
65
92
  ### Standard Usage
66
93
 
@@ -86,11 +113,11 @@ depgraph ./src --no-color --output ./ci/depgraph.json
86
113
 
87
114
  ---
88
115
 
89
- ### 🧬 Git Diff Integration
116
+ ### Git Diff Integration
90
117
 
91
118
  `--git-impact` automatically reads your git diff, detects every function or class that changed, and runs an impact simulation for each one β€” no need to manually select a target entity.
92
119
 
93
- #### βš™οΈ How It Works under the Hood
120
+ #### How It Works under the Hood
94
121
 
95
122
  1. **Git Diff Execution**: Runs the appropriate git command depending on the mode:
96
123
  - **Uncommitted Changes**: `git diff HEAD` (detects staged & unstaged changes).
@@ -101,7 +128,7 @@ depgraph ./src --no-color --output ./ci/depgraph.json
101
128
  4. **Fallback Parsers**: Contains built-in fallback parser logic for popular OOP languages like Java (`.java`) and C# (`.cs`) to extract method signatures.
102
129
  5. **Change Description Generation**: Automatically analyzes added/removed lines in the change hunk to build descriptive labels (e.g. `getUserById: 3 line(s) changed to 2 new line(s)`).
103
130
 
104
- #### πŸ“‹ Git Commands Reference
131
+ #### Git Commands Reference
105
132
 
106
133
  | Mode | CLI Command | Under-the-hood Command | Description |
107
134
  | :--- | :--- | :--- | :--- |
@@ -110,7 +137,7 @@ depgraph ./src --no-color --output ./ci/depgraph.json
110
137
  | **Specific Commit** | `depgraph ./src --git-impact --commit <sha>` | `git diff <sha>~1 <sha>` | Analyze any commit by its SHA |
111
138
  | **Branch Comparison** | `depgraph ./src --git-impact --from main --to feature/auth` | `git diff main...feature/auth` | Compare two branches |
112
139
 
113
- #### πŸ–₯️ CLI Output Example
140
+ #### CLI Output Example
114
141
 
115
142
  Running `--git-impact` displays a colorized report of detected entities and runs an impact simulation for each one:
116
143
 
@@ -119,14 +146,14 @@ Running `--git-impact` displays a colorized report of detected entities and runs
119
146
  DepGraph v1.0.0
120
147
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
121
148
 
122
- πŸ” Scanning .
149
+ Scanning .
123
150
 
124
- πŸ“Š Graph Summary
151
+ Graph Summary
125
152
  Files : 27
126
153
  Nodes : 76
127
154
  Edges : 252
128
155
 
129
- πŸ” Reading git diff...
156
+ Reading git diff...
130
157
 
131
158
  Found 2 changed entity(s):
132
159
  β†’ slugify (src/languages/javascript.ts)
@@ -136,7 +163,7 @@ Running impact simulation...
136
163
 
137
164
  ──────────────────────────────────────────
138
165
 
139
- πŸ’₯ Impact Simulation
166
+ Impact Simulation
140
167
  Target : slugify__javascript
141
168
  Change : slugify: 16 line(s) added
142
169
  Risk Score : 0
@@ -144,22 +171,22 @@ Running impact simulation...
144
171
 
145
172
  βœ“ No affected nodes found
146
173
 
147
- πŸ§ͺ Testing Plan
174
+ Testing Plan
148
175
  β†’ Test slugify directly after making changes
149
176
 
150
- πŸ’‘ Recommendations
177
+ Recommendations
151
178
  β†’ Standard PR process is sufficient
152
179
  β†’ Unit tests for the changed node are enough
153
180
 
154
181
  ──────────────────────────────────────────
155
182
 
156
- πŸ’₯ Impact Simulation
183
+ Impact Simulation
157
184
  Target : LanguageParser__registry
158
185
  Change : LanguageParser: 6 line(s) added
159
186
  Risk Score : 100
160
187
  Risk Level : CRITICAL
161
188
 
162
- πŸ“‹ Affected Nodes (3)
189
+ Affected Nodes (3)
163
190
 
164
191
  [CRITICAL] extractEntities
165
192
  file : src/languages/go.ts
@@ -179,27 +206,27 @@ Running impact simulation...
179
206
  action : Update extractExports to handle the new interface of LanguageParser
180
207
  breaking: YES
181
208
 
182
- πŸ§ͺ Testing Plan
209
+ Testing Plan
183
210
  β†’ Test LanguageParser directly after making changes
184
211
  β†’ Regression test extractEntities β€” direct dependent
185
212
  β†’ Regression test extractImports β€” direct dependent
186
213
  β†’ Regression test extractExports β€” direct dependent
187
214
  β†’ Run full test suite β€” 3 nodes affected
188
215
 
189
- πŸ’‘ Recommendations
216
+ Recommendations
190
217
  β†’ Full team review required before merging
191
218
  β†’ Consider a phased rollout
192
219
  β†’ Run full regression test suite
193
220
  β†’ 3 breaking change(s) must be updated before deploying
194
221
 
195
- βœ… Output written to ./depgraph-output.json
222
+ Output written to ./depgraph-output.json
196
223
  ```
197
224
 
198
- **Supported languages for diff parsing:** JavaScript/TypeScript, Python, Go. Java and C# method signatures are handled via a built-in fallback.
225
+ **Supported languages for diff parsing:** All 10 languages (JavaScript/TypeScript, Python, Go, C#, Java, Kotlin, PHP, Ruby, and Swift) are fully supported via shared entity pattern registries and fallbacks.
199
226
 
200
227
  ---
201
228
 
202
- ## πŸ’₯ Impact Simulation Mechanics
229
+ ## Impact Simulation Mechanics
203
230
 
204
231
  When running `--impact` or `--git-impact`, the tool performs:
205
232
 
@@ -211,14 +238,14 @@ When running `--impact` or `--git-impact`, the tool performs:
211
238
  - Number of medium/low-impact nodes
212
239
  - The target node's in-degree
213
240
  4. **Risk Level Mapping**:
214
- - πŸ”΄ **CRITICAL** (β‰₯ 75): Comprehensive review, phased rollout, full regression testing.
215
- - 🟑 **HIGH** (50–74): Tech lead review, feature flag recommended.
216
- - πŸ”΅ **MEDIUM** (25–49): Standard peer review, targeted module testing.
217
- - 🟒 **LOW** (< 25): Standard PR process is sufficient.
241
+ - **CRITICAL** (β‰₯ 75): Comprehensive review, phased rollout, full regression testing.
242
+ - **HIGH** (50–74): Tech lead review, feature flag recommended.
243
+ - **MEDIUM** (25–49): Standard peer review, targeted module testing.
244
+ - **LOW** (< 25): Standard PR process is sufficient.
218
245
 
219
246
  ---
220
247
 
221
- ## πŸ“ Output JSON Schema
248
+ ## Output JSON Schema
222
249
 
223
250
  ```json
224
251
  {
@@ -276,7 +303,7 @@ When running `--impact` or `--git-impact`, the tool performs:
276
303
 
277
304
  ---
278
305
 
279
- ## πŸ’» Development & Contribution
306
+ ## Development & Contribution
280
307
 
281
308
  ### Setup
282
309
  ```bash
@@ -297,6 +324,6 @@ npm install
297
324
 
298
325
  ---
299
326
 
300
- ## πŸ“„ License
327
+ ## License
301
328
 
302
329
  This project is licensed under the MIT License β€” see the [LICENSE](LICENSE) file for details.