@getcodesentinel/codesentinel 1.6.5 → 1.8.0
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 +85 -22
- package/dist/index.js +1328 -37
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -69,6 +69,8 @@ Then run:
|
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
71
|
codesentinel analyze [path]
|
|
72
|
+
codesentinel explain [path]
|
|
73
|
+
codesentinel report [path]
|
|
72
74
|
codesentinel dependency-risk <dependency[@version]>
|
|
73
75
|
```
|
|
74
76
|
|
|
@@ -78,6 +80,14 @@ Examples:
|
|
|
78
80
|
codesentinel analyze
|
|
79
81
|
codesentinel analyze .
|
|
80
82
|
codesentinel analyze ../project
|
|
83
|
+
codesentinel explain
|
|
84
|
+
codesentinel explain . --top 5 --format text
|
|
85
|
+
codesentinel explain . --file src/app/page.tsx
|
|
86
|
+
codesentinel explain . --module src/components
|
|
87
|
+
codesentinel report
|
|
88
|
+
codesentinel report --format md --output report.md
|
|
89
|
+
codesentinel report --snapshot snapshot.json
|
|
90
|
+
codesentinel report --compare baseline.json --format text
|
|
81
91
|
codesentinel dependency-risk react
|
|
82
92
|
codesentinel dependency-risk react@19.0.0
|
|
83
93
|
```
|
|
@@ -103,6 +113,26 @@ codesentinel analyze .
|
|
|
103
113
|
# Full output (all sections and detailed arrays)
|
|
104
114
|
codesentinel analyze . --output json
|
|
105
115
|
codesentinel analyze . --json
|
|
116
|
+
|
|
117
|
+
# Explain top hotspots with narrative output
|
|
118
|
+
codesentinel explain .
|
|
119
|
+
|
|
120
|
+
# Explain a specific file
|
|
121
|
+
codesentinel explain . --file src/app/page.tsx
|
|
122
|
+
|
|
123
|
+
# Explain a specific module
|
|
124
|
+
codesentinel explain . --module src/components
|
|
125
|
+
|
|
126
|
+
# Explain in markdown or json
|
|
127
|
+
codesentinel explain . --format md
|
|
128
|
+
codesentinel explain . --format json
|
|
129
|
+
|
|
130
|
+
# Report generation (human + machine readable)
|
|
131
|
+
codesentinel report .
|
|
132
|
+
codesentinel report . --format md --output report.md
|
|
133
|
+
codesentinel report . --format json
|
|
134
|
+
codesentinel report . --snapshot snapshot.json
|
|
135
|
+
codesentinel report . --compare baseline.json --format text
|
|
106
136
|
```
|
|
107
137
|
|
|
108
138
|
Notes:
|
|
@@ -124,8 +154,51 @@ pnpm dev -- analyze
|
|
|
124
154
|
pnpm dev -- analyze .
|
|
125
155
|
pnpm dev -- analyze ../project
|
|
126
156
|
pnpm dev -- analyze . --author-identity strict_email
|
|
157
|
+
pnpm dev -- explain
|
|
158
|
+
pnpm dev -- explain . --top 5 --format text
|
|
159
|
+
pnpm dev -- explain . --file src/app/page.tsx
|
|
160
|
+
pnpm dev -- report
|
|
161
|
+
pnpm dev -- report . --format md --output report.md
|
|
162
|
+
pnpm dev -- report . --compare baseline.json --format text
|
|
127
163
|
```
|
|
128
164
|
|
|
165
|
+
## Report Output
|
|
166
|
+
|
|
167
|
+
`codesentinel report` produces deterministic engineering artifacts from existing analysis outputs.
|
|
168
|
+
|
|
169
|
+
- formats: `text`, `md`, `json`
|
|
170
|
+
- optional file output: `--output <path>`
|
|
171
|
+
- optional snapshot export: `--snapshot <path>`
|
|
172
|
+
- optional diff mode: `--compare <baseline.json>`
|
|
173
|
+
|
|
174
|
+
Diff mode compares snapshots and reports:
|
|
175
|
+
|
|
176
|
+
- repository score deltas
|
|
177
|
+
- file/module risk deltas
|
|
178
|
+
- new/resolved hotspots
|
|
179
|
+
- new/resolved cycles
|
|
180
|
+
- dependency exposure list changes
|
|
181
|
+
|
|
182
|
+
## Explain Output
|
|
183
|
+
|
|
184
|
+
`codesentinel explain` uses the same risk-engine scoring model as `analyze` and adds structured explanation traces.
|
|
185
|
+
|
|
186
|
+
Text/markdown output includes:
|
|
187
|
+
|
|
188
|
+
- repository score and risk band (`low|moderate|high|very_high`)
|
|
189
|
+
- plain-language primary drivers
|
|
190
|
+
- concrete evidence values behind those drivers
|
|
191
|
+
- intersected signals (composite interaction terms)
|
|
192
|
+
- prioritized reduction actions
|
|
193
|
+
- per-target breakdowns (repository/file/module/dependency, depending on selection)
|
|
194
|
+
|
|
195
|
+
Filters:
|
|
196
|
+
|
|
197
|
+
- `--file <path>`: explain one file target.
|
|
198
|
+
- `--module <name>`: explain one module target.
|
|
199
|
+
- `--top <n>`: explain top `n` hotspot files (default behavior when no file/module is provided).
|
|
200
|
+
- `--format text|json|md`: render narrative text, full JSON payload, or markdown.
|
|
201
|
+
|
|
129
202
|
## Understanding Analyze Output
|
|
130
203
|
|
|
131
204
|
`codesentinel analyze` returns one JSON document with four top-level blocks:
|
|
@@ -201,12 +274,24 @@ For `external.dependencies`, each direct dependency now exposes three signal fie
|
|
|
201
274
|
- `inheritedRiskSignals`: signals propagated from transitive dependencies in its subtree.
|
|
202
275
|
- `riskSignals`: union of `ownRiskSignals` and `inheritedRiskSignals`.
|
|
203
276
|
|
|
277
|
+
Data source notes:
|
|
278
|
+
|
|
279
|
+
- Lockfile-first extraction supports `pnpm-lock.yaml`, `package-lock.json` / `npm-shrinkwrap.json`, `yarn.lock`, and `bun.lock`.
|
|
280
|
+
- If no lockfile is present, CodeSentinel attempts a bounded npm registry graph resolution from direct dependencies.
|
|
281
|
+
- npm weekly download metadata is fetched only for direct dependencies (not all transitive nodes).
|
|
282
|
+
|
|
204
283
|
Classification lists:
|
|
205
284
|
|
|
206
285
|
- `highRiskDependencies`: **production** direct packages classified from strong **own** signals (not inherited-only signals).
|
|
207
286
|
- `highRiskDevelopmentDependencies`: same classification model for direct development dependencies.
|
|
208
287
|
- `transitiveExposureDependencies`: direct packages carrying inherited transitive exposure signals.
|
|
209
288
|
|
|
289
|
+
Current high-risk rule for direct dependencies:
|
|
290
|
+
|
|
291
|
+
- mark high-risk if own signals include `abandoned`, or
|
|
292
|
+
- mark high-risk if at least two of own signals are in `{high_centrality, deep_chain, high_fanout}`, or
|
|
293
|
+
- mark high-risk if own signals include `single_maintainer` and the package is stale (>= half abandoned threshold) or has no recent repository activity signal.
|
|
294
|
+
|
|
210
295
|
Propagation policy is explicit and deterministic:
|
|
211
296
|
|
|
212
297
|
- `single_maintainer`: **not propagated**
|
|
@@ -225,28 +310,6 @@ Propagation policy is explicit and deterministic:
|
|
|
225
310
|
|
|
226
311
|
This keeps package-level facts local while still surfacing meaningful transitive exposure.
|
|
227
312
|
|
|
228
|
-
## Release Automation
|
|
229
|
-
|
|
230
|
-
- Pull requests to `main` run build and tests via `.github/workflows/ci.yml`.
|
|
231
|
-
- Pull requests and release runs also validate the packed CLI artifact (`npm pack`) with install/execute smoke checks before publish.
|
|
232
|
-
- Merges to `main` run semantic-release via `.github/workflows/release.yml`.
|
|
233
|
-
- semantic-release bumps `packages/cli/package.json`, creates a GitHub release, publishes to npm, and pushes the version-bump commit back to `main`.
|
|
234
|
-
- Dependabot is configured monthly in `.github/dependabot.yml` for npm and GitHub Actions updates.
|
|
235
|
-
|
|
236
|
-
Trusted Publisher setup (no `NPM_TOKEN` secret):
|
|
237
|
-
|
|
238
|
-
- In npm package settings for `@getcodesentinel/codesentinel`, add a Trusted Publisher.
|
|
239
|
-
- Provider: `GitHub Actions`.
|
|
240
|
-
- Repository: `getcodesentinel/codesentinel`.
|
|
241
|
-
- Workflow filename: `release.yml`.
|
|
242
|
-
- Environment name: leave empty unless you explicitly use a GitHub Actions environment in this workflow.
|
|
243
|
-
|
|
244
|
-
Commit messages on `main` should follow Conventional Commits (example: `feat:`, `fix:`, `chore:`) so semantic-release can calculate versions automatically.
|
|
245
|
-
|
|
246
|
-
## Contributing
|
|
247
|
-
|
|
248
|
-
This project aims to be production-grade and minimal. If you add new dependencies or abstractions, justify them clearly and keep the architecture clean.
|
|
249
|
-
|
|
250
313
|
## ESM Import Policy
|
|
251
314
|
|
|
252
315
|
- The workspace uses `TypeScript` with `moduleResolution: "NodeNext"` and ESM output.
|