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/.vscode/depgraph-output.json +4634 -0
- package/README.md +64 -37
- package/depgraph-output.json +404 -47
- package/depgraph.js +1295 -74
- package/docs/stage-impact.md +4 -4
- package/docs/stage-output.md +2 -2
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,25 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DepGraph Core
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/depgraph-core)
|
|
4
4
|
[](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
|
|
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
|
-
##
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
###
|
|
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
|
-
####
|
|
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
|
-
####
|
|
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
|
-
####
|
|
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
|
-
|
|
149
|
+
Scanning .
|
|
123
150
|
|
|
124
|
-
|
|
151
|
+
Graph Summary
|
|
125
152
|
Files : 27
|
|
126
153
|
Nodes : 76
|
|
127
154
|
Edges : 252
|
|
128
155
|
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
174
|
+
Testing Plan
|
|
148
175
|
β Test slugify directly after making changes
|
|
149
176
|
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
222
|
+
Output written to ./depgraph-output.json
|
|
196
223
|
```
|
|
197
224
|
|
|
198
|
-
**Supported languages for diff parsing:** JavaScript/TypeScript, Python, Go
|
|
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
|
-
##
|
|
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
|
-
-
|
|
215
|
-
-
|
|
216
|
-
-
|
|
217
|
-
-
|
|
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
|
-
##
|
|
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
|
-
##
|
|
306
|
+
## Development & Contribution
|
|
280
307
|
|
|
281
308
|
### Setup
|
|
282
309
|
```bash
|
|
@@ -297,6 +324,6 @@ npm install
|
|
|
297
324
|
|
|
298
325
|
---
|
|
299
326
|
|
|
300
|
-
##
|
|
327
|
+
## License
|
|
301
328
|
|
|
302
329
|
This project is licensed under the MIT License β see the [LICENSE](LICENSE) file for details.
|