@getcodesentinel/codesentinel 1.36.0 → 1.38.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 +18 -1
- package/dist/index.js +878 -155
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,7 @@ codesentinel report [path]
|
|
|
150
150
|
codesentinel check [path]
|
|
151
151
|
codesentinel ci [path]
|
|
152
152
|
codesentinel owners [path]
|
|
153
|
+
codesentinel comment --input <file> [--pr <number>] [--comment-on change|always|never]
|
|
153
154
|
codesentinel trend --from <dir-or-glob>
|
|
154
155
|
codesentinel init [path]
|
|
155
156
|
codesentinel dependency-risk <dependency[@version]>
|
|
@@ -178,7 +179,10 @@ codesentinel ci --baseline-ref origin/main --max-risk-delta 0.03 --no-new-cycles
|
|
|
178
179
|
codesentinel ci --baseline-ref auto --fail-on error
|
|
179
180
|
codesentinel owners
|
|
180
181
|
codesentinel owners . --format md --output ownership.md
|
|
182
|
+
codesentinel owners . --format sarif --output codesentinel-ownership.sarif
|
|
181
183
|
codesentinel owners . --fail-on error --max-unowned-critical 0 --max-ghost-owners 2 --max-drift 0.25
|
|
184
|
+
codesentinel comment --input codesentinel-ci.json
|
|
185
|
+
codesentinel comment --input codesentinel-ci.json --pr 42 --comment-on change
|
|
182
186
|
codesentinel trend --from ./snapshots
|
|
183
187
|
codesentinel trend --from './snapshots/*.json' --since 90d --format md --output trend.md
|
|
184
188
|
codesentinel init
|
|
@@ -193,7 +197,11 @@ Use `codesentinel update` to manually check for a newer CLI release and install
|
|
|
193
197
|
|
|
194
198
|
`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
199
|
|
|
196
|
-
|
|
200
|
+
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.
|
|
201
|
+
|
|
202
|
+
`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.
|
|
203
|
+
|
|
204
|
+
`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
205
|
|
|
198
206
|
Author identity mode:
|
|
199
207
|
|
|
@@ -333,6 +341,8 @@ Ownership violations are error-level, so `--fail-on` never softens them; `--fail
|
|
|
333
341
|
|
|
334
342
|
`codesentinel ci` orchestrates snapshot + diff + gate evaluation + markdown summary generation.
|
|
335
343
|
|
|
344
|
+
`--snapshot <path>` writes a `codesentinel.snapshot.v2` artifact. Whenever a `CODEOWNERS` file exists, the snapshot embeds the ownership audit block (`ownership`) independently of the ownership thresholds, which only control enforcement. It also records `source.commit` (the full SHA) and `source.ref`, so `trend` can show the revision each run measured.
|
|
345
|
+
|
|
336
346
|
Baseline input modes:
|
|
337
347
|
|
|
338
348
|
- `--baseline <path>`: use an existing snapshot JSON artifact.
|
|
@@ -345,6 +355,8 @@ Baseline input modes:
|
|
|
345
355
|
- otherwise: `merge-base(HEAD, origin/main)` then `origin/master`, `main`, `master`
|
|
346
356
|
- `--main-branch <name>` (repeatable) or `--main-branches "main,master,trunk"` customize default branch candidates used by `--baseline-ref auto`.
|
|
347
357
|
|
|
358
|
+
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.
|
|
359
|
+
|
|
348
360
|
GitHub Actions recommendation for deterministic CI with `--baseline-ref auto`:
|
|
349
361
|
|
|
350
362
|
```yaml
|
|
@@ -379,9 +391,12 @@ Exit codes:
|
|
|
379
391
|
```bash
|
|
380
392
|
codesentinel owners
|
|
381
393
|
codesentinel owners . --format md --output ownership.md
|
|
394
|
+
codesentinel owners . --format sarif --output codesentinel-ownership.sarif
|
|
382
395
|
codesentinel ci --max-unowned-critical 0 --max-ghost-owners 2 --max-drift 0.25 --fail-on error
|
|
383
396
|
```
|
|
384
397
|
|
|
398
|
+
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.
|
|
399
|
+
|
|
385
400
|
### Sample output
|
|
386
401
|
|
|
387
402
|
The following is illustrative output from a small four-file repository (plus its `CODEOWNERS` file), run with `--min-commits 2`:
|
|
@@ -442,6 +457,8 @@ This measures system risk, not individual performance. No owner or author rankin
|
|
|
442
457
|
|
|
443
458
|
`codesentinel trend` reads snapshot JSON artifacts written by `codesentinel ci --snapshot` and prints the series over time. Snapshots are CI artifacts, not repository files: `trend` never writes history into the repository and never changes the snapshot schema.
|
|
444
459
|
|
|
460
|
+
The workflow generated by `codesentinel init` runs `codesentinel ci --snapshot` and uploads the result as the `codesentinel` artifact, retrievable with `gh run download <run-id> -n codesentinel`. The ownership columns (Unowned, Ghosts, Drift) are populated from the snapshot's embedded ownership block, and the Commit column shows the short SHA. Both `codesentinel.snapshot.v2` and legacy `codesentinel.snapshot.v1` artifacts are read; v1 snapshots have no commit, so Commit shows `—`.
|
|
461
|
+
|
|
445
462
|
```bash
|
|
446
463
|
codesentinel trend --from ./snapshots
|
|
447
464
|
codesentinel trend --from './snapshots/*.json' --since 90d --last 12 --format md --output trend.md
|