@getcodesentinel/codesentinel 1.8.0 → 1.9.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 +105 -0
- package/dist/index.js +3763 -2833
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -13,6 +13,66 @@ CodeSentinel is a structural and evolutionary risk analysis engine for modern Ty
|
|
|
13
13
|
|
|
14
14
|
This repository contains the CodeSentinel monorepo, with structural, evolution, external dependency, and deterministic risk analysis engines exposed through a CLI.
|
|
15
15
|
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### 1) Install
|
|
19
|
+
|
|
20
|
+
Global install (good for local/manual usage):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g @getcodesentinel/codesentinel
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Project/CI install (recommended for CI and reproducibility):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install --save-dev @getcodesentinel/codesentinel
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2) Analyze a project
|
|
33
|
+
|
|
34
|
+
Run commands from the repository root you want to analyze. If you run from another directory, pass the target path explicitly (for example `codesentinel analyze /path/to/project`).
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
codesentinel analyze
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3) Generate a report
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
codesentinel report --format md --output codesentinel-report.md
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 4) Run in CI
|
|
47
|
+
|
|
48
|
+
Using local project install (no global install required):
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx codesentinel ci --baseline-ref auto --fail-on error
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or in package scripts:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"scripts": {
|
|
59
|
+
"risk:ci": "codesentinel ci --baseline-ref auto --fail-on error"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
CI example:
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
- uses: actions/checkout@v4
|
|
68
|
+
with:
|
|
69
|
+
fetch-depth: 0
|
|
70
|
+
- name: Run CodeSentinel
|
|
71
|
+
run: npx codesentinel ci --baseline-ref auto --max-repo-score 55 --max-repo-delta 0.03 --no-new-cycles --no-new-high-risk-deps --max-new-hotspots 2 --fail-on error
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`--baseline-ref auto` requires enough git history to resolve a baseline deterministically. In GitHub Actions, use `fetch-depth: 0`.
|
|
75
|
+
|
|
16
76
|
## Vision
|
|
17
77
|
|
|
18
78
|
CodeSentinel combines three signals into a single, explainable risk profile:
|
|
@@ -40,6 +100,7 @@ The goal is a practical, engineering-grade model that supports both strategic ar
|
|
|
40
100
|
- `packages/dependency-firewall`: external dependency and supply chain signals.
|
|
41
101
|
- `packages/risk-engine`: risk aggregation and scoring model.
|
|
42
102
|
- `packages/reporter`: structured report output (console, JSON, CI).
|
|
103
|
+
- `packages/governance`: CI gate evaluation and enforcement policy checks.
|
|
43
104
|
- `packages/cli`: user-facing CLI entrypoint.
|
|
44
105
|
|
|
45
106
|
Each package is standalone, ESM-only, TypeScript-first, and built with `tsup`. The CLI depends on `core`; domain packages are kept decoupled to avoid circular dependencies.
|
|
@@ -71,6 +132,8 @@ Then run:
|
|
|
71
132
|
codesentinel analyze [path]
|
|
72
133
|
codesentinel explain [path]
|
|
73
134
|
codesentinel report [path]
|
|
135
|
+
codesentinel check [path]
|
|
136
|
+
codesentinel ci [path]
|
|
74
137
|
codesentinel dependency-risk <dependency[@version]>
|
|
75
138
|
```
|
|
76
139
|
|
|
@@ -88,6 +151,10 @@ codesentinel report
|
|
|
88
151
|
codesentinel report --format md --output report.md
|
|
89
152
|
codesentinel report --snapshot snapshot.json
|
|
90
153
|
codesentinel report --compare baseline.json --format text
|
|
154
|
+
codesentinel check --compare baseline.json --max-repo-delta 0.03 --no-new-cycles
|
|
155
|
+
codesentinel ci --baseline baseline.json --snapshot current.json --report report.md --fail-on error
|
|
156
|
+
codesentinel ci --baseline-ref origin/main --max-repo-delta 0.03 --no-new-cycles
|
|
157
|
+
codesentinel ci --baseline-ref auto --fail-on error
|
|
91
158
|
codesentinel dependency-risk react
|
|
92
159
|
codesentinel dependency-risk react@19.0.0
|
|
93
160
|
```
|
|
@@ -160,6 +227,8 @@ pnpm dev -- explain . --file src/app/page.tsx
|
|
|
160
227
|
pnpm dev -- report
|
|
161
228
|
pnpm dev -- report . --format md --output report.md
|
|
162
229
|
pnpm dev -- report . --compare baseline.json --format text
|
|
230
|
+
pnpm dev -- check . --compare baseline.json --max-repo-delta 0.03 --no-new-cycles
|
|
231
|
+
pnpm dev -- ci . --baseline baseline.json --snapshot current.json --report report.md --fail-on warn
|
|
163
232
|
```
|
|
164
233
|
|
|
165
234
|
## Report Output
|
|
@@ -179,6 +248,42 @@ Diff mode compares snapshots and reports:
|
|
|
179
248
|
- new/resolved cycles
|
|
180
249
|
- dependency exposure list changes
|
|
181
250
|
|
|
251
|
+
## CI Mode
|
|
252
|
+
|
|
253
|
+
`codesentinel check` evaluates enforcement gates against current analysis (and optional baseline diff).
|
|
254
|
+
|
|
255
|
+
Supported gates:
|
|
256
|
+
|
|
257
|
+
- `--max-repo-delta <value>`
|
|
258
|
+
- `--no-new-cycles`
|
|
259
|
+
- `--no-new-high-risk-deps`
|
|
260
|
+
- `--max-new-hotspots <count>`
|
|
261
|
+
- `--max-repo-score <score>`
|
|
262
|
+
- `--new-hotspot-score-threshold <score>`
|
|
263
|
+
- `--fail-on error|warn`
|
|
264
|
+
|
|
265
|
+
`codesentinel ci` orchestrates snapshot + diff + gate evaluation + markdown summary generation.
|
|
266
|
+
|
|
267
|
+
Baseline input modes:
|
|
268
|
+
|
|
269
|
+
- `--baseline <path>`: use an existing snapshot JSON artifact.
|
|
270
|
+
- `--baseline-ref <git-ref>`: resolve baseline from git (`origin/main`, `main`, `HEAD~1`) using an isolated temporary worktree. No checkout/stash of your current working tree.
|
|
271
|
+
- `--baseline-ref auto`: deterministic resolver with ordered fallbacks:
|
|
272
|
+
- `--baseline-sha <sha>` if provided.
|
|
273
|
+
- CI base branch env vars (`GITHUB_BASE_REF`, `CI_MERGE_REQUEST_TARGET_BRANCH_NAME`, `BITBUCKET_PR_DESTINATION_BRANCH`) with `origin/<branch>` first, then `<branch>`.
|
|
274
|
+
- branch-aware defaults:
|
|
275
|
+
- on `main/master`: `HEAD~1`
|
|
276
|
+
- otherwise: `merge-base(HEAD, origin/main)` then `origin/master`, `main`, `master`
|
|
277
|
+
- `--main-branch <name>` (repeatable) or `--main-branches "main,master,trunk"` customize default branch candidates used by `--baseline-ref auto`.
|
|
278
|
+
|
|
279
|
+
Exit codes:
|
|
280
|
+
|
|
281
|
+
- `0`: no failing violations
|
|
282
|
+
- `1`: error-level violations
|
|
283
|
+
- `2`: warn-level violations when `--fail-on=warn`
|
|
284
|
+
- `3`: invalid configuration
|
|
285
|
+
- `4`: internal execution error
|
|
286
|
+
|
|
182
287
|
## Explain Output
|
|
183
288
|
|
|
184
289
|
`codesentinel explain` uses the same risk-engine scoring model as `analyze` and adds structured explanation traces.
|