@getcodesentinel/codesentinel 1.37.0 → 1.39.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 +19 -3
- package/dist/index.js +696 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
<a href="https://github.com/getcodesentinel/codesentinel/actions/workflows/release.yml"><img src="https://github.com/getcodesentinel/codesentinel/actions/workflows/release.yml/badge.svg?branch=main" alt="Release" /></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/@getcodesentinel/codesentinel"><img src="https://img.shields.io/npm/v/@getcodesentinel/codesentinel" alt="npm version" /></a>
|
|
8
8
|
<a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D22-339933?logo=node.js&logoColor=white" alt="Node.js >=22" /></a>
|
|
9
|
-
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a
|
|
9
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a>
|
|
10
|
+
<a href="https://getcodesentinel.github.io/codesentinel/"><img src="https://img.shields.io/badge/live%20report-GitHub%20Pages-222?logo=github" alt="Live report" /></a>
|
|
10
11
|
</p>
|
|
11
12
|
|
|
12
13
|
CodeSentinel is a structural and evolutionary risk analysis engine for modern TypeScript/JavaScript codebases. It turns architecture, change history, and dependency health into a unified risk model that helps engineering teams spot fragility before it becomes failure.
|
|
@@ -150,6 +151,7 @@ codesentinel report [path]
|
|
|
150
151
|
codesentinel check [path]
|
|
151
152
|
codesentinel ci [path]
|
|
152
153
|
codesentinel owners [path]
|
|
154
|
+
codesentinel comment --input <file> [--pr <number>] [--comment-on change|always|never]
|
|
153
155
|
codesentinel trend --from <dir-or-glob>
|
|
154
156
|
codesentinel init [path]
|
|
155
157
|
codesentinel dependency-risk <dependency[@version]>
|
|
@@ -178,7 +180,10 @@ codesentinel ci --baseline-ref origin/main --max-risk-delta 0.03 --no-new-cycles
|
|
|
178
180
|
codesentinel ci --baseline-ref auto --fail-on error
|
|
179
181
|
codesentinel owners
|
|
180
182
|
codesentinel owners . --format md --output ownership.md
|
|
183
|
+
codesentinel owners . --format sarif --output codesentinel-ownership.sarif
|
|
181
184
|
codesentinel owners . --fail-on error --max-unowned-critical 0 --max-ghost-owners 2 --max-drift 0.25
|
|
185
|
+
codesentinel comment --input codesentinel-ci.json
|
|
186
|
+
codesentinel comment --input codesentinel-ci.json --pr 42 --comment-on change
|
|
182
187
|
codesentinel trend --from ./snapshots
|
|
183
188
|
codesentinel trend --from './snapshots/*.json' --since 90d --format md --output trend.md
|
|
184
189
|
codesentinel init
|
|
@@ -193,7 +198,11 @@ Use `codesentinel update` to manually check for a newer CLI release and install
|
|
|
193
198
|
|
|
194
199
|
`codesentinel owners` cross-checks the owners declared in `CODEOWNERS` with the authors that history proves. It is offline, reads the `CODEOWNERS` file and the tracked tree from `--ref` so CI and a local run measure the same revision, and exits with `0` when the audit ran, `1` when a configured threshold is exceeded under `--fail-on error`, and `2` on a configuration or parse error (an untracked `CODEOWNERS`, an invalid flag value, or a file above GitHub's 3 MB limit). A repository without a `CODEOWNERS` file reports `available: false` and still exits `0`.
|
|
195
200
|
|
|
196
|
-
|
|
201
|
+
Use `--format sarif` to emit SARIF 2.1.0 for GitHub code scanning. Each ownership finding maps to one of the four rules (`ownership/unowned-critical`, `ownership/ghost-owner`, `ownership/drift`, `ownership/unknown`), points at line 1 of the file, and links back to the matching `CODEOWNERS` line when one exists. Results carry stable `codesentinel/v1` partial fingerprints derived only from the rule id and the relative path, so repeated uploads deduplicate instead of opening duplicate alerts. Upload it with `github/codeql-action/upload-sarif` and the `codesentinel-ownership` category. When no `CODEOWNERS` file exists the log still declares all four rules and contains zero results.
|
|
202
|
+
|
|
203
|
+
`codesentinel comment --input <file>` renders the sticky pull request summary from the JSON written by `codesentinel ci --json-output`. Pass `--pr <number>` to upsert it through the GitHub API; the token is read from `GITHUB_TOKEN` only, never a flag, and `--repository` defaults to `GITHUB_REPOSITORY`. The comment is marked with `<!-- codesentinel:summary -->`, so later runs update it in place instead of creating another comment. `--comment-on change` (the default) skips the API update when nothing moved, `always` refreshes it unconditionally, and `never` renders without posting. Without `--pr` the command is a local renderer and prints the body to stdout unless `--output <file>` is given.
|
|
204
|
+
|
|
205
|
+
`codesentinel init [path]` scaffolds a working CI setup in the target repository. It writes `.github/workflows/codesentinel.yml` and, when a `CODEOWNERS` file exists, `.codesentinel/owners.json`. The workflow runs `codesentinel ci --baseline-ref auto --fail-on error --snapshot codesentinel-snapshot.json --json-output codesentinel-ci.json`, builds an ownership report and a SARIF file when a `CODEOWNERS` file is present, uploads the SARIF to GitHub code scanning, posts the sticky pull request summary, and uploads the snapshot and report artifacts with 90-day retention. The uploaded snapshot includes ownership data when a `CODEOWNERS` file exists, so `codesentinel trend` can chart ownership history from those artifacts. Use `--force` to overwrite existing generated files, `--ci none` to skip the workflow (for example when CI lives elsewhere), or `--dry-run` to print what would be written without changing anything. Existing files are never overwritten without `--force`, and the command never edits `package.json`.
|
|
197
206
|
|
|
198
207
|
Author identity mode:
|
|
199
208
|
|
|
@@ -286,7 +295,7 @@ pnpm dev -- ci . --baseline baseline.json --snapshot current.json --report repor
|
|
|
286
295
|
`codesentinel report` produces deterministic engineering artifacts from existing analysis outputs.
|
|
287
296
|
|
|
288
297
|
- default format: `md`
|
|
289
|
-
- formats: `text`, `md`, `json`
|
|
298
|
+
- formats: `text`, `md`, `json`, `html` (`--format html` writes a self-contained `index.html` into the `--output` directory)
|
|
290
299
|
- optional file output: `--output <path>`
|
|
291
300
|
- optional snapshot export: `--snapshot <path>`
|
|
292
301
|
- optional diff mode: `--compare <baseline.json>`
|
|
@@ -299,6 +308,8 @@ Diff mode compares snapshots and reports:
|
|
|
299
308
|
- new/resolved cycles
|
|
300
309
|
- dependency exposure list changes
|
|
301
310
|
|
|
311
|
+
The live report at <https://getcodesentinel.github.io/codesentinel/> is this project's own HTML report generated by CodeSentinel from this repository and refreshed on every push to `main`.
|
|
312
|
+
|
|
302
313
|
## Run Output
|
|
303
314
|
|
|
304
315
|
`codesentinel run` is a convenience command that emits `analyze + explain + report` in one execution.
|
|
@@ -347,6 +358,8 @@ Baseline input modes:
|
|
|
347
358
|
- otherwise: `merge-base(HEAD, origin/main)` then `origin/master`, `main`, `master`
|
|
348
359
|
- `--main-branch <name>` (repeatable) or `--main-branches "main,master,trunk"` customize default branch candidates used by `--baseline-ref auto`.
|
|
349
360
|
|
|
361
|
+
The workflow generated by `codesentinel init` now uploads ownership SARIF to code scanning and posts the sticky pull request summary, so it needs `security-events: write` and `pull-requests: write` in addition to `contents: read`. If your repository manages permissions centrally, grant those two explicitly or the SARIF upload and comment steps will fail.
|
|
362
|
+
|
|
350
363
|
GitHub Actions recommendation for deterministic CI with `--baseline-ref auto`:
|
|
351
364
|
|
|
352
365
|
```yaml
|
|
@@ -381,9 +394,12 @@ Exit codes:
|
|
|
381
394
|
```bash
|
|
382
395
|
codesentinel owners
|
|
383
396
|
codesentinel owners . --format md --output ownership.md
|
|
397
|
+
codesentinel owners . --format sarif --output codesentinel-ownership.sarif
|
|
384
398
|
codesentinel ci --max-unowned-critical 0 --max-ghost-owners 2 --max-drift 0.25 --fail-on error
|
|
385
399
|
```
|
|
386
400
|
|
|
401
|
+
The SARIF format is intended for GitHub code scanning: upload `codesentinel-ownership.sarif` with `github/codeql-action/upload-sarif` and `category: codesentinel-ownership`. Findings keep stable fingerprints, so code scanning updates the same alerts across runs.
|
|
402
|
+
|
|
387
403
|
### Sample output
|
|
388
404
|
|
|
389
405
|
The following is illustrative output from a small four-file repository (plus its `CODEOWNERS` file), run with `--min-commits 2`:
|