@anirudw/repolens 0.2.0 → 0.2.3
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 +5 -54
- package/dist/index.js +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Repolens
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
3
7
|
**A cross-platform, multi-lingual repository intelligence CLI.**
|
|
4
8
|
|
|
5
9
|
Repolens analyzes your codebase using tree-sitter ASTs to map dependency networks, identify architectural pillars, and calculate coupling metrics.
|
|
@@ -10,57 +14,4 @@ Repolens analyzes your codebase using tree-sitter ASTs to map dependency network
|
|
|
10
14
|
## Install
|
|
11
15
|
|
|
12
16
|
```bash
|
|
13
|
-
npm install -g @anirudw/repolens
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Quick Start
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
# Analyze a repository
|
|
20
|
-
repolens ./my-project
|
|
21
|
-
|
|
22
|
-
# Export dependency graph
|
|
23
|
-
repolens ./my-project --format json --output graph.json
|
|
24
|
-
|
|
25
|
-
# Find implementations of an interface
|
|
26
|
-
repolens ./my-project --implements ILogger
|
|
27
|
-
|
|
28
|
-
# View architectural health metrics
|
|
29
|
-
repolens ./my-project --health
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Options
|
|
33
|
-
|
|
34
|
-
| Flag | Description |
|
|
35
|
-
|------|-------------|
|
|
36
|
-
| `-v, --verbose` | Enable verbose output |
|
|
37
|
-
| `-f, --format` | Output format: `text` (default) or `json` |
|
|
38
|
-
| `-o, --output <file>` | Output file path |
|
|
39
|
-
| `-i, --implements <name>` | Find files implementing an interface |
|
|
40
|
-
| `--health` | Display architectural health metrics |
|
|
41
|
-
|
|
42
|
-
## Features
|
|
43
|
-
|
|
44
|
-
- **Multi-lingual AST parsing** — JavaScript, TypeScript, Python, Java, Markdown
|
|
45
|
-
- **Path resolution** — Automatically resolves local imports
|
|
46
|
-
- **PageRank centrality** — Identifies the most relied-upon files
|
|
47
|
-
- **Entry-point detection** — Flags critical entry points
|
|
48
|
-
- **Interface registry** — Track class/interface relationships
|
|
49
|
-
- **Health metrics** — Coupling (Ca, Ce) and instability (I)
|
|
50
|
-
|
|
51
|
-
## Health Metrics
|
|
52
|
-
|
|
53
|
-
The `--health` flag calculates coupling metrics:
|
|
54
|
-
|
|
55
|
-
- **Ca (Afferent Coupling)** — Files that depend on this file
|
|
56
|
-
- **Ce (Efferent Coupling)** — Files this file depends on
|
|
57
|
-
- **Instability** — `I = Ce / (Ca + Ce)`
|
|
58
|
-
|
|
59
|
-
| Value | Meaning |
|
|
60
|
-
|-------|---------|
|
|
61
|
-
| ~0 | Stable core dependency |
|
|
62
|
-
| ~1 | Highly unstable (fragile) |
|
|
63
|
-
|
|
64
|
-
## License
|
|
65
|
-
|
|
66
|
-
MIT
|
|
17
|
+
npm install -g @anirudw/repolens
|
package/dist/index.js
CHANGED
|
@@ -1012,22 +1012,23 @@ function createCommand() {
|
|
|
1012
1012
|
graph.calculateHealthMetrics();
|
|
1013
1013
|
if (options.health) {
|
|
1014
1014
|
const nodes = Array.from(graph.getNodes().values());
|
|
1015
|
+
console.log("Total nodes:", nodes.length);
|
|
1015
1016
|
const topCoreDeps = nodes.sort((a, b) => b.ca - a.ca).slice(0, 5).filter((n) => n.ca > 0);
|
|
1016
1017
|
const topUnstable = nodes.sort((a, b) => b.instability - a.instability).slice(0, 5).filter((n) => n.instability > 0);
|
|
1017
|
-
console.log(
|
|
1018
|
+
console.log("\n=== Architectural Health Metrics ===\n");
|
|
1019
|
+
console.log("Core deps count:", topCoreDeps.length);
|
|
1020
|
+
console.log("Unstable count:", topUnstable.length);
|
|
1018
1021
|
if (topCoreDeps.length > 0) {
|
|
1019
|
-
console.log(
|
|
1022
|
+
console.log("\nTop 5 Core Dependencies:");
|
|
1020
1023
|
for (const node of topCoreDeps) {
|
|
1021
|
-
console.log(` ${
|
|
1024
|
+
console.log(` ${node.relativePath}: ${node.ca} dependents`);
|
|
1022
1025
|
}
|
|
1023
|
-
console.log();
|
|
1024
1026
|
}
|
|
1025
1027
|
if (topUnstable.length > 0) {
|
|
1026
|
-
console.log(
|
|
1028
|
+
console.log("\nTop 5 Unstable Files:");
|
|
1027
1029
|
for (const node of topUnstable) {
|
|
1028
|
-
console.log(` ${
|
|
1030
|
+
console.log(` ${node.relativePath}: ${node.instability.toFixed(3)} instability`);
|
|
1029
1031
|
}
|
|
1030
|
-
console.log();
|
|
1031
1032
|
}
|
|
1032
1033
|
process.exit(0);
|
|
1033
1034
|
}
|