dep-brain 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- ## Unreleased
6
-
7
- - Workspace-aware analysis for npm workspaces.
8
- - Config loading and CI policy controls.
9
- - Improved duplicate detection and unused dependency heuristics.
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## Unreleased
6
+
7
+ - Workspace-aware analysis for npm workspaces.
8
+ - Config loading and CI policy controls.
9
+ - Improved duplicate detection and unused dependency heuristics.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Vijay prakash
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vijay prakash
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,197 +1,197 @@
1
- # Dependency Brain
2
-
3
- [![npm version](https://img.shields.io/npm/v/dep-brain)](https://www.npmjs.com/package/dep-brain)
4
- [![npm downloads](https://img.shields.io/npm/dm/dep-brain)](https://www.npmjs.com/package/dep-brain)
5
- [![license](https://img.shields.io/npm/l/dep-brain)](LICENSE)
6
-
7
- `dep-brain` is a CLI and library for analyzing dependency health in JavaScript and TypeScript projects.
8
-
9
- ## Vision
10
-
11
- `npm audit + depcheck + dedupe + intelligence = one tool`
12
-
13
- ## What It Does
14
-
15
- - Detect duplicate dependencies from `package-lock.json`
16
- - Detect likely unused dependencies from source imports and scripts
17
- - Detect outdated packages
18
- - Highlight dependency risk signals
19
- - Generate a simple project health score
20
- - Output reports in human-readable or JSON format
21
-
22
- ## Current MVP Features
23
-
24
- - Duplicate dependency detection with lockfile instance tracking
25
- - Unused dependency detection with runtime vs dev-tool heuristics
26
- - Outdated dependency reporting with `major`, `minor`, and `patch` classification
27
- - Risk analysis based on npm package metadata
28
- - Config loading from `depbrain.config.json`
29
- - Ignore rules for noisy dependencies and checks
30
- - CI-friendly policy evaluation with non-zero exit codes
31
- - Workspace-aware analysis for npm workspaces
32
- - Console reporting
33
- - JSON output via `--json`
34
- - Library entrypoint for programmatic use
35
-
36
- ## CLI Usage
37
-
38
- ```bash
39
- npm install -g dep-brain
40
- dep-brain analyze
41
-
42
- npx dep-brain analyze
43
- npx dep-brain analyze --json
44
- npx dep-brain analyze ./path-to-project
45
- npx dep-brain analyze --config depbrain.config.json
46
- npx dep-brain analyze --min-score 90 --fail-on-risks
47
- npx dep-brain analyze ./path-to-project --fail-on-unused --json
48
-
49
- dep-brain config
50
- dep-brain config --config depbrain.config.json
51
-
52
- dep-brain help
53
- dep-brain analyze --help
54
- ```
55
-
56
- ## Workspaces
57
-
58
- If the root `package.json` defines `workspaces`, `dep-brain` analyzes each workspace package and reports per-package results. Aggregated counts are still shown at the top-level summary.
59
-
60
- ## Example Output
61
-
62
- ```text
63
- Project Health: 78/100
64
- Path: /your/project
65
- Policy: FAIL
66
-
67
- WARN Duplicates: 2
68
- OK Unused: 0
69
- WARN Outdated: 3
70
- OK Risks: 0
71
-
72
- Duplicate dependencies:
73
- - ansi-regex: 5.0.1, 6.0.1
74
-
75
- Outdated dependencies:
76
- - chalk: ^4.1.2 -> 5.4.1 [major]
77
-
78
- Policy reasons:
79
- - Score 78 is below minimum 90
80
-
81
- Suggestions:
82
- - Consider consolidating ansi-regex to one version
83
- - Review chalk: ^4.1.2 -> 5.4.1 (major)
84
- ```
85
-
86
- ## JSON Output
87
-
88
- ```bash
89
- dep-brain analyze --json
90
- ```
91
-
92
- ## Config File
93
-
94
- Create a `depbrain.config.json` file in the project root:
95
-
96
- ```json
97
- {
98
- "ignore": {
99
- "unused": ["eslint"],
100
- "outdated": ["typescript"]
101
- },
102
- "policy": {
103
- "minScore": 90,
104
- "failOnUnused": true,
105
- "failOnRisks": true
106
- },
107
- "report": {
108
- "maxSuggestions": 3
109
- }
110
- }
111
- ```
112
-
113
- Supported sections:
114
-
115
- - `ignore.dependencies`
116
- - `ignore.devDependencies`
117
- - `ignore.unused`
118
- - `ignore.duplicates`
119
- - `ignore.outdated`
120
- - `ignore.risks`
121
- - `policy.minScore`
122
- - `policy.failOnDuplicates`
123
- - `policy.failOnUnused`
124
- - `policy.failOnOutdated`
125
- - `policy.failOnRisks`
126
- - `report.maxSuggestions`
127
-
128
- Sample config file:
129
-
130
- - `depbrain.config.json`
131
- - `depbrain.config.schema.json`
132
-
133
- ## CI Behavior
134
-
135
- `dep-brain` now returns a non-zero exit code when configured policy checks fail.
136
-
137
- Examples:
138
-
139
- ```bash
140
- dep-brain analyze --fail-on-unused
141
- dep-brain analyze --min-score 85 --fail-on-risks
142
- dep-brain analyze --config depbrain.config.json
143
- ```
144
-
145
- ## Config Debugging
146
-
147
- Print the resolved config (after defaults and CLI overrides):
148
-
149
- ```bash
150
- dep-brain config
151
- dep-brain config --config depbrain.config.json
152
- ```
153
-
154
- ## Development
155
-
156
- ```bash
157
- npm install
158
- npm run typecheck
159
- npm run test
160
- npm run build
161
- ```
162
-
163
- ## Project Structure
164
-
165
- ```text
166
- src/
167
- |-- cli.ts
168
- |-- index.ts
169
- |-- core/
170
- | |-- analyzer.ts
171
- | |-- graph-builder.ts
172
- | `-- scorer.ts
173
- |-- checks/
174
- | |-- duplicate.ts
175
- | |-- unused.ts
176
- | |-- outdated.ts
177
- | `-- risk.ts
178
- |-- reporters/
179
- | |-- console.ts
180
- | `-- json.ts
181
- `-- utils/
182
- |-- file-parser.ts
183
- |-- npm-api.ts
184
- `-- config.ts
185
- ```
186
-
187
- ## Roadmap Direction
188
-
189
- - Improve false-positive reduction for unused dependency detection
190
- - Improve monorepo and workspace support
191
- - Strengthen risk scoring and suggestions
192
- - Add CI and GitHub Action support in later releases
193
-
194
- ## Repository Notes
195
-
196
- - Project brief: [docs/project-brief.md](./docs/project-brief.md)
197
- - Implementation history: [docs/implementation-log.md](./docs/implementation-log.md)
1
+ # Dependency Brain
2
+
3
+ [![npm version](https://img.shields.io/npm/v/dep-brain)](https://www.npmjs.com/package/dep-brain)
4
+ [![npm downloads](https://img.shields.io/npm/dm/dep-brain)](https://www.npmjs.com/package/dep-brain)
5
+ [![license](https://img.shields.io/npm/l/dep-brain)](LICENSE)
6
+
7
+ `dep-brain` is a CLI and library for analyzing dependency health in JavaScript and TypeScript projects.
8
+
9
+ ## Vision
10
+
11
+ `npm audit + depcheck + dedupe + intelligence = one tool`
12
+
13
+ ## What It Does
14
+
15
+ - Detect duplicate dependencies from `package-lock.json`
16
+ - Detect likely unused dependencies from source imports and scripts
17
+ - Detect outdated packages
18
+ - Highlight dependency risk signals
19
+ - Generate a simple project health score
20
+ - Output reports in human-readable or JSON format
21
+
22
+ ## Current MVP Features
23
+
24
+ - Duplicate dependency detection with lockfile instance tracking
25
+ - Unused dependency detection with runtime vs dev-tool heuristics
26
+ - Outdated dependency reporting with `major`, `minor`, and `patch` classification
27
+ - Risk analysis based on npm package metadata
28
+ - Config loading from `depbrain.config.json`
29
+ - Ignore rules for noisy dependencies and checks
30
+ - CI-friendly policy evaluation with non-zero exit codes
31
+ - Workspace-aware analysis for npm workspaces
32
+ - Console reporting
33
+ - JSON output via `--json`
34
+ - Library entrypoint for programmatic use
35
+
36
+ ## CLI Usage
37
+
38
+ ```bash
39
+ npm install -g dep-brain
40
+ dep-brain analyze
41
+
42
+ npx dep-brain analyze
43
+ npx dep-brain analyze --json
44
+ npx dep-brain analyze ./path-to-project
45
+ npx dep-brain analyze --config depbrain.config.json
46
+ npx dep-brain analyze --min-score 90 --fail-on-risks
47
+ npx dep-brain analyze ./path-to-project --fail-on-unused --json
48
+
49
+ dep-brain config
50
+ dep-brain config --config depbrain.config.json
51
+
52
+ dep-brain help
53
+ dep-brain analyze --help
54
+ ```
55
+
56
+ ## Workspaces
57
+
58
+ If the root `package.json` defines `workspaces`, `dep-brain` analyzes each workspace package and reports per-package results. Aggregated counts are still shown at the top-level summary.
59
+
60
+ ## Example Output
61
+
62
+ ```text
63
+ Project Health: 78/100
64
+ Path: /your/project
65
+ Policy: FAIL
66
+
67
+ WARN Duplicates: 2
68
+ OK Unused: 0
69
+ WARN Outdated: 3
70
+ OK Risks: 0
71
+
72
+ Duplicate dependencies:
73
+ - ansi-regex: 5.0.1, 6.0.1
74
+
75
+ Outdated dependencies:
76
+ - chalk: ^4.1.2 -> 5.4.1 [major]
77
+
78
+ Policy reasons:
79
+ - Score 78 is below minimum 90
80
+
81
+ Suggestions:
82
+ - Consider consolidating ansi-regex to one version
83
+ - Review chalk: ^4.1.2 -> 5.4.1 (major)
84
+ ```
85
+
86
+ ## JSON Output
87
+
88
+ ```bash
89
+ dep-brain analyze --json
90
+ ```
91
+
92
+ ## Config File
93
+
94
+ Create a `depbrain.config.json` file in the project root:
95
+
96
+ ```json
97
+ {
98
+ "ignore": {
99
+ "unused": ["eslint"],
100
+ "outdated": ["typescript"]
101
+ },
102
+ "policy": {
103
+ "minScore": 90,
104
+ "failOnUnused": true,
105
+ "failOnRisks": true
106
+ },
107
+ "report": {
108
+ "maxSuggestions": 3
109
+ }
110
+ }
111
+ ```
112
+
113
+ Supported sections:
114
+
115
+ - `ignore.dependencies`
116
+ - `ignore.devDependencies`
117
+ - `ignore.unused`
118
+ - `ignore.duplicates`
119
+ - `ignore.outdated`
120
+ - `ignore.risks`
121
+ - `policy.minScore`
122
+ - `policy.failOnDuplicates`
123
+ - `policy.failOnUnused`
124
+ - `policy.failOnOutdated`
125
+ - `policy.failOnRisks`
126
+ - `report.maxSuggestions`
127
+
128
+ Sample config file:
129
+
130
+ - `depbrain.config.json`
131
+ - `depbrain.config.schema.json`
132
+
133
+ ## CI Behavior
134
+
135
+ `dep-brain` now returns a non-zero exit code when configured policy checks fail.
136
+
137
+ Examples:
138
+
139
+ ```bash
140
+ dep-brain analyze --fail-on-unused
141
+ dep-brain analyze --min-score 85 --fail-on-risks
142
+ dep-brain analyze --config depbrain.config.json
143
+ ```
144
+
145
+ ## Config Debugging
146
+
147
+ Print the resolved config (after defaults and CLI overrides):
148
+
149
+ ```bash
150
+ dep-brain config
151
+ dep-brain config --config depbrain.config.json
152
+ ```
153
+
154
+ ## Development
155
+
156
+ ```bash
157
+ npm install
158
+ npm run typecheck
159
+ npm run test
160
+ npm run build
161
+ ```
162
+
163
+ ## Project Structure
164
+
165
+ ```text
166
+ src/
167
+ |-- cli.ts
168
+ |-- index.ts
169
+ |-- core/
170
+ | |-- analyzer.ts
171
+ | |-- graph-builder.ts
172
+ | `-- scorer.ts
173
+ |-- checks/
174
+ | |-- duplicate.ts
175
+ | |-- unused.ts
176
+ | |-- outdated.ts
177
+ | `-- risk.ts
178
+ |-- reporters/
179
+ | |-- console.ts
180
+ | `-- json.ts
181
+ `-- utils/
182
+ |-- file-parser.ts
183
+ |-- npm-api.ts
184
+ `-- config.ts
185
+ ```
186
+
187
+ ## Roadmap Direction
188
+
189
+ - Improve false-positive reduction for unused dependency detection
190
+ - Improve monorepo and workspace support
191
+ - Strengthen risk scoring and suggestions
192
+ - Add CI and GitHub Action support in later releases
193
+
194
+ ## Repository Notes
195
+
196
+ - Project brief: [docs/project-brief.md](./docs/project-brief.md)
197
+ - Implementation history: [docs/implementation-log.md](./docs/implementation-log.md)
@@ -1,20 +1,20 @@
1
- {
2
- "ignore": {
3
- "unused": [],
4
- "outdated": [],
5
- "duplicates": [],
6
- "risks": [],
7
- "dependencies": [],
8
- "devDependencies": []
9
- },
10
- "policy": {
11
- "minScore": 85,
12
- "failOnUnused": false,
13
- "failOnOutdated": false,
14
- "failOnDuplicates": false,
15
- "failOnRisks": false
16
- },
17
- "report": {
18
- "maxSuggestions": 5
19
- }
20
- }
1
+ {
2
+ "ignore": {
3
+ "unused": [],
4
+ "outdated": [],
5
+ "duplicates": [],
6
+ "risks": [],
7
+ "dependencies": [],
8
+ "devDependencies": []
9
+ },
10
+ "policy": {
11
+ "minScore": 85,
12
+ "failOnUnused": false,
13
+ "failOnOutdated": false,
14
+ "failOnDuplicates": false,
15
+ "failOnRisks": false
16
+ },
17
+ "report": {
18
+ "maxSuggestions": 5
19
+ }
20
+ }
@@ -1,38 +1,38 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "Dependency Brain Config",
4
- "type": "object",
5
- "additionalProperties": false,
6
- "properties": {
7
- "ignore": {
8
- "type": "object",
9
- "additionalProperties": false,
10
- "properties": {
11
- "dependencies": { "type": "array", "items": { "type": "string" } },
12
- "devDependencies": { "type": "array", "items": { "type": "string" } },
13
- "unused": { "type": "array", "items": { "type": "string" } },
14
- "duplicates": { "type": "array", "items": { "type": "string" } },
15
- "outdated": { "type": "array", "items": { "type": "string" } },
16
- "risks": { "type": "array", "items": { "type": "string" } }
17
- }
18
- },
19
- "policy": {
20
- "type": "object",
21
- "additionalProperties": false,
22
- "properties": {
23
- "minScore": { "type": "number" },
24
- "failOnUnused": { "type": "boolean" },
25
- "failOnOutdated": { "type": "boolean" },
26
- "failOnDuplicates": { "type": "boolean" },
27
- "failOnRisks": { "type": "boolean" }
28
- }
29
- },
30
- "report": {
31
- "type": "object",
32
- "additionalProperties": false,
33
- "properties": {
34
- "maxSuggestions": { "type": "number" }
35
- }
36
- }
37
- }
38
- }
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Dependency Brain Config",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "ignore": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "dependencies": { "type": "array", "items": { "type": "string" } },
12
+ "devDependencies": { "type": "array", "items": { "type": "string" } },
13
+ "unused": { "type": "array", "items": { "type": "string" } },
14
+ "duplicates": { "type": "array", "items": { "type": "string" } },
15
+ "outdated": { "type": "array", "items": { "type": "string" } },
16
+ "risks": { "type": "array", "items": { "type": "string" } }
17
+ }
18
+ },
19
+ "policy": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "properties": {
23
+ "minScore": { "type": "number" },
24
+ "failOnUnused": { "type": "boolean" },
25
+ "failOnOutdated": { "type": "boolean" },
26
+ "failOnDuplicates": { "type": "boolean" },
27
+ "failOnRisks": { "type": "boolean" }
28
+ }
29
+ },
30
+ "report": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "properties": {
34
+ "maxSuggestions": { "type": "number" }
35
+ }
36
+ }
37
+ }
38
+ }
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "dep-brain",
3
- "version": "0.1.0",
4
- "description": "CLI and library for dependency health analysis",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "bin": {
9
- "dep-brain": "dist/cli.js"
10
- },
11
- "files": [
12
- "dist",
13
- "README.md",
14
- "LICENSE",
15
- "CHANGELOG.md",
16
- "depbrain.config.json",
17
- "depbrain.config.schema.json"
18
- ],
19
- "scripts": {
20
- "build": "tsc -p tsconfig.json",
21
- "clean": "if exist dist rmdir /s /q dist",
22
- "dev": "tsx src/cli.ts analyze",
23
- "start": "node dist/cli.js analyze",
24
- "test": "npm run build && node tests/run.js",
25
- "typecheck": "tsc -p tsconfig.json --noEmit"
26
- },
27
- "keywords": [
28
- "dependencies",
29
- "cli",
30
- "analysis",
31
- "npm",
32
- "audit"
33
- ],
34
- "author": "",
35
- "license": "MIT",
36
- "repository": {
37
- "type": "git",
38
- "url": "git+ssh://git@github.com/prakashu51/dep-brain.git"
39
- },
40
- "bugs": {
41
- "url": "https://github.com/prakashu51/dep-brain/issues"
42
- },
43
- "homepage": "https://github.com/prakashu51/dep-brain#readme",
44
- "engines": {
45
- "node": ">=18"
46
- },
47
- "dependencies": {},
48
- "devDependencies": {
49
- "@types/node": "^24.5.2",
50
- "tsx": "^4.20.5",
51
- "typescript": "^5.9.2"
52
- }
53
- }
1
+ {
2
+ "name": "dep-brain",
3
+ "version": "0.1.1",
4
+ "description": "CLI and library for dependency health analysis",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "dep-brain": "dist/cli.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE",
15
+ "CHANGELOG.md",
16
+ "depbrain.config.json",
17
+ "depbrain.config.schema.json"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "clean": "if exist dist rmdir /s /q dist",
22
+ "dev": "tsx src/cli.ts analyze",
23
+ "start": "node dist/cli.js analyze",
24
+ "test": "npm run build && node tests/run.js",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit"
26
+ },
27
+ "keywords": [
28
+ "dependencies",
29
+ "cli",
30
+ "analysis",
31
+ "npm",
32
+ "audit"
33
+ ],
34
+ "author": "",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+ssh://git@github.com/prakashu51/dep-brain.git"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/prakashu51/dep-brain/issues"
42
+ },
43
+ "homepage": "https://github.com/prakashu51/dep-brain#readme",
44
+ "engines": {
45
+ "node": ">=18"
46
+ },
47
+ "dependencies": {},
48
+ "devDependencies": {
49
+ "@types/node": "^24.5.2",
50
+ "tsx": "^4.20.5",
51
+ "typescript": "^5.9.2"
52
+ }
53
+ }