@agenticcli/shipguard 0.11.0 → 0.12.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
@@ -51,6 +51,8 @@ shipguard hook --target ci # GitHub Actions verdict job
51
51
 
52
52
  Copy-paste snippets for `AGENTS.md`, `CLAUDE.md` and CI: [docs/placement-kit.md](docs/placement-kit.md).
53
53
 
54
+ The CLI downloads rules from the rulebook; your code never leaves your machine; only usage telemetry is sent (off with the opt-outs below).
55
+
54
56
  ## Exit codes
55
57
 
56
58
  ShipGuard is triggered by an agent; output is read machine-readably (`--json`).
@@ -61,11 +63,13 @@ and `degraded`/`degradedReasons` fields for that.
61
63
 
62
64
  | Code | Meaning |
63
65
  |------|---------|
64
- | `0` | Scan completed — verdict is in the JSON `recommendation` field. Returned even if findings are blocking, and even if the scan is degraded/partial. |
66
+ | `0` | Scan completed — verdict is in the JSON `recommendation` field. Returned even if findings are blocking, and even if the scan is degraded/partial. **Not "safe".** |
65
67
  | `1` | Blocked — **only** with `--strict`, and then on either a blocking finding **or** a scan that did not finish (`degraded: true`). An unfinished scan cannot clear a hard gate. |
66
68
  | `2` | Config error, strictly (bad policy file, bad flags, non-project directory). Never doubles as "degraded scan." |
67
69
  | `3` | Runtime error — the scan could not meaningfully run at all. |
68
70
 
71
+ So that a `0` is never read as "passed": when blocking findings exist and `--strict` is off, the terminal output ends with `exit 0 = scan finished, not safe. Add --strict to fail on blocking findings.`, and `--json` carries the same sentence in `exitMeaning`. `shipguard --help` lists the codes too.
72
+
69
73
  A degraded/partial scan (e.g. pro rules unavailable, an oversized file skipped)
70
74
  is exit `0` with `degraded: true` and a `degradedReasons[]` array in `--json`
71
75
  output — it never hijacks exit `2`, which is reserved for genuine config errors.
@@ -83,14 +87,14 @@ turned into spaces. Real binaries (images, fonts, archives) are counted and are
83
87
  problem. A scan that read **nothing** (`NO_FILES_SCANNED`, for example an empty folder or a
84
88
  `--changed` scan where every changed file was ignored), an unknown binary blob (`UNSCANNED_UNKNOWN_BINARY`), and a
85
89
  truncated scan are `degraded` and so `DO_NOT_SHIP`. To clear a blob you trust, add its path to
86
- `ignore.paths`. `--changed` when nothing changed at all is different: there is nothing to
87
- check, so it is not degraded and `coverage.changed.nothingToCheck` is `true` (`filesScanned` is
88
- `0`). Do not use that as proof a project is safe: run a full `shipguard scan` for that. Some formats are counted but their contents are not scanned: SQLite files
90
+ `ignore.paths`. `--changed` when nothing changed at all is the same: nothing was scanned, so it is `degraded`
91
+ (`NO_FILES_SCANNED`, `DO_NOT_SHIP`, `--strict` exits `1`) and also sets `coverage.changed.nothingToCheck: true`
92
+ (`filesScanned` is `0`). It is never a pass: run a full `shipguard scan` for that. Some formats are counted but their contents are not scanned: SQLite files
89
93
  outside the ASCII reading, compressed archives, and string tables inside ELF, PE, class and WASM files.
90
94
 
91
95
  ## Telemetry
92
96
 
93
- Published ShipGuard builds send one pseudonymous usage ping after each scan, plus a one-off ping on the first run on an install and one after a successful `shipguard login` (7 keys: `schema`, `event`, `eventId`, `installId`, `cliVersion`, `provenance`, `ci`; the first-run ping is never sent in CI). A scan ping carries 8 keys: `schema`, `eventId`, `installId` (random pseudonym), `cliVersion`, `provenance` (build type), `verdict` (safe / review / blocked / error), `durationBucket` and `ci`. An optional `traffic` key (`test` or `internal`) is added only if you set `SHIPGUARD_TRAFFIC`; any other value is ignored. The install id is a pseudonym stored in `~/.config/shipguard/telemetry.json`; not created or sent in CI, never linked to an account. Never file contents, paths, repo names, branches or commits, or user identity. `shipguard telemetry status` shows what is set, `shipguard telemetry reset` forgets the id (earlier pings can be deleted on request), `SHIPGUARD_TELEMETRY_DEBUG=1` prints the exact payload without sending. Builds from a source checkout never send anything.
97
+ **The CLI downloads rules from the rulebook; your code never leaves your machine; only usage telemetry is sent (off with the opt-outs below).** Published ShipGuard builds send one pseudonymous usage ping after each scan, plus a one-off ping on the first run on an install and one after a successful `shipguard login` (7 keys: `schema`, `event`, `eventId`, `installId`, `cliVersion`, `provenance`, `ci`; the first-run ping is never sent in CI). A scan ping carries 11 keys: `schema` (`4`), `eventId`, `installId` (random pseudonym), `cliVersion`, `provenance` (build type), `verdict` (safe / review / blocked / error), `durationBucket`, `ci`, and three about how ShipGuard was run: `agent` (`claude_code`, `codex`, `cursor`, `gemini_cli`, `copilot`, `opencode`, `other_agent` or `none`, from the variables the agent itself sets in your environment; only the label is sent, never a value), `interactive` (is the output a terminal) and `output` (`json`, `human` or `sarif`). Pings go to `agenticcli.dev/api/cli-telemetry` (host agenticcli.dev). Every `--json` result shows `"telemetry": "on"` or `"off"`. An optional `traffic` key (`test` or `internal`) is added only if you set `SHIPGUARD_TRAFFIC`; any other value is ignored. The install id is a pseudonym stored in `~/.config/shipguard/telemetry.json`; not created or sent in CI, never linked to an account. Never file contents, paths, repo names, branches or commits, or user identity. `shipguard telemetry status` shows what is set, `shipguard telemetry reset` forgets the id (earlier pings can be deleted on request), `SHIPGUARD_TELEMETRY_DEBUG=1` prints the exact payload without sending. Builds from a source checkout never send anything.
94
98
 
95
99
  Before the first ping on a machine, ShipGuard prints a one-line notice to stderr (in every mode, including `--json` and CI, so stdout stays clean). Turn pings off any of these ways:
96
100
 
@@ -1,7 +1,7 @@
1
1
  {
2
- "secrets": "cab8ba95cd53c7a453270d50e009defa7065babd4c06939fcd641fd117eab5b3",
3
- "auth": "cab8ba95cd53c7a453270d50e009defa7065babd4c06939fcd641fd117eab5b3",
4
- "database": "cab8ba95cd53c7a453270d50e009defa7065babd4c06939fcd641fd117eab5b3",
5
- "deployment": "cab8ba95cd53c7a453270d50e009defa7065babd4c06939fcd641fd117eab5b3",
6
- "payments": "cab8ba95cd53c7a453270d50e009defa7065babd4c06939fcd641fd117eab5b3"
2
+ "secrets": "3a385cd0a01454b8f7aa46686083033060dee3b722903f6b1047a892aaa4ca23",
3
+ "auth": "3a385cd0a01454b8f7aa46686083033060dee3b722903f6b1047a892aaa4ca23",
4
+ "database": "3a385cd0a01454b8f7aa46686083033060dee3b722903f6b1047a892aaa4ca23",
5
+ "deployment": "3a385cd0a01454b8f7aa46686083033060dee3b722903f6b1047a892aaa4ca23",
6
+ "payments": "3a385cd0a01454b8f7aa46686083033060dee3b722903f6b1047a892aaa4ca23"
7
7
  }
@@ -298,6 +298,18 @@ function effectiveRecommendation(result) {
298
298
  return result.recommendation ?? result.riskScore.recommendation;
299
299
  }
300
300
 
301
+ // src/utils/cwd-guard.ts
302
+ import { realpathSync } from "fs";
303
+ function assertCwdAlive() {
304
+ try {
305
+ realpathSync.native(".");
306
+ } catch (err) {
307
+ throw new Error(
308
+ `The folder being scanned no longer exists (removed or moved during the scan): ${err instanceof Error ? err.message : String(err)}`
309
+ );
310
+ }
311
+ }
312
+
301
313
  // src/core/report.ts
302
314
  function severitySection(title, findings) {
303
315
  if (findings.length === 0) {
@@ -445,6 +457,7 @@ async function generateReport(result, outputPath, elapsedMs) {
445
457
  runJson: runJsonName,
446
458
  runMarkdown: runMdName
447
459
  };
460
+ assertCwdAlive();
448
461
  await mkdir(dir, { recursive: true });
449
462
  await mkdir(join(dir, RUNS_SUBDIR), { recursive: true });
450
463
  await Promise.all([
@@ -888,6 +901,7 @@ export {
888
901
  computeVerdict,
889
902
  applyVerdict,
890
903
  effectiveRecommendation,
904
+ assertCwdAlive,
891
905
  generateReport,
892
906
  buildIgnoreRules,
893
907
  classifyIgnored,