@getcodesentinel/codesentinel 1.37.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 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
- `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`, builds an ownership report when a `CODEOWNERS` file is present, and uploads both 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`.
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
 
@@ -347,6 +355,8 @@ Baseline input modes:
347
355
  - otherwise: `merge-base(HEAD, origin/main)` then `origin/master`, `main`, `master`
348
356
  - `--main-branch <name>` (repeatable) or `--main-branches "main,master,trunk"` customize default branch candidates used by `--baseline-ref auto`.
349
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
+
350
360
  GitHub Actions recommendation for deterministic CI with `--baseline-ref auto`:
351
361
 
352
362
  ```yaml
@@ -381,9 +391,12 @@ Exit codes:
381
391
  ```bash
382
392
  codesentinel owners
383
393
  codesentinel owners . --format md --output ownership.md
394
+ codesentinel owners . --format sarif --output codesentinel-ownership.sarif
384
395
  codesentinel ci --max-unowned-critical 0 --max-ghost-owners 2 --max-drift 0.25 --fail-on error
385
396
  ```
386
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
+
387
400
  ### Sample output
388
401
 
389
402
  The following is illustrative output from a small four-file repository (plus its `CODEOWNERS` file), run with `--min-commits 2`: