@agenticcli/shipguard 0.5.0 → 0.6.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
@@ -30,8 +30,23 @@ shipguard scan --quiet # One-line verdict only
30
30
  shipguard scan --pro # Pro rules — requires login
31
31
  shipguard login # Authenticate for Pro rules
32
32
  shipguard init # Generate .shipguard.yml policy file
33
+ shipguard hook # Install the gate at the merge boundary (git / claude / ci)
34
+ shipguard schema --json # The machine-readable contract: verdict values, exit codes, limits
33
35
  ```
34
36
 
37
+ ### Put the gate where merges happen
38
+
39
+ ShipGuard never blocks on its own. Installing a hook is the deliberate act that turns the
40
+ hard stop on:
41
+
42
+ ```bash
43
+ shipguard hook # git pre-push + pre-merge-commit
44
+ shipguard hook --target claude # Claude Code hook — runs outside the model
45
+ shipguard hook --target ci # GitHub Actions verdict job
46
+ ```
47
+
48
+ Copy-paste snippets for `AGENTS.md`, `CLAUDE.md` and CI: [docs/placement-kit.md](docs/placement-kit.md).
49
+
35
50
  ## Exit codes
36
51
 
37
52
  ShipGuard is triggered by an agent; output is read machine-readably (`--json`).
@@ -43,7 +58,7 @@ and `degraded`/`degradedReasons` fields for that.
43
58
  | Code | Meaning |
44
59
  |------|---------|
45
60
  | `0` | Scan completed — verdict is in the JSON `recommendation` field. Returned even if findings are blocking, and even if the scan is degraded/partial. |
46
- | `1` | Blocked — **only** with `--strict` + at least one blocking finding. |
61
+ | `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. |
47
62
  | `2` | Config error, strictly (bad policy file, bad flags, non-project directory). Never doubles as "degraded scan." |
48
63
  | `3` | Runtime error — the scan could not meaningfully run at all. |
49
64
 
@@ -51,6 +66,10 @@ A degraded/partial scan (e.g. pro rules unavailable, an oversized file skipped)
51
66
  is exit `0` with `degraded: true` and a `degradedReasons[]` array in `--json`
52
67
  output — it never hijacks exit `2`, which is reserved for genuine config errors.
53
68
 
69
+ **A degraded scan is always `DO_NOT_SHIP`.** The report tells the truth about what it could
70
+ not check; the exit code stays 0 because ShipGuard is passive by default. Pass `--strict`
71
+ when you want that truthful verdict to actually stop something.
72
+
54
73
  ## Telemetry
55
74
 
56
75
  ShipGuard sends an anonymous usage ping on each scan (verdict bucket, duration, CLI version, CI flag — never file contents, paths, or user identity). Opt out: `SHIPGUARD_TELEMETRY=0` or `DO_NOT_TRACK=1`.
@@ -1,7 +1,7 @@
1
1
  {
2
- "secrets": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
3
- "auth": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
4
- "database": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
5
- "deployment": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c",
6
- "payments": "62af17fb25c0a77d8affc8cc37f697e81a0fe5bc9c675d3650156e4dc500922c"
2
+ "secrets": "a0ef525812bbdfc10499302db78d7747238726e5dc10a14bcfc247c35048b181",
3
+ "auth": "a0ef525812bbdfc10499302db78d7747238726e5dc10a14bcfc247c35048b181",
4
+ "database": "a0ef525812bbdfc10499302db78d7747238726e5dc10a14bcfc247c35048b181",
5
+ "deployment": "a0ef525812bbdfc10499302db78d7747238726e5dc10a14bcfc247c35048b181",
6
+ "payments": "a0ef525812bbdfc10499302db78d7747238726e5dc10a14bcfc247c35048b181"
7
7
  }
@@ -3,7 +3,7 @@ import {
3
3
  detectBinary,
4
4
  normalizeNewlines,
5
5
  stripBom
6
- } from "./chunk-5T42QTNT.js";
6
+ } from "./chunk-MPQ42F54.js";
7
7
 
8
8
  // src/utils/fs.ts
9
9
  import fg from "fast-glob";
@@ -53,6 +53,9 @@ var DEFAULT_IGNORE = [
53
53
  ".shipguard/**"
54
54
  ];
55
55
  var MAX_SKIPPED_NAMES = 50;
56
+ function compareScanPaths(a, b) {
57
+ return a < b ? -1 : a > b ? 1 : 0;
58
+ }
56
59
  async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], options = {}) {
57
60
  const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
58
61
  const maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
@@ -74,11 +77,32 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
74
77
  // load-bearing that we set it false explicitly.
75
78
  followSymbolicLinks: false
76
79
  });
80
+ filePaths.sort(compareScanPaths);
81
+ const symlinkProbeEntries = await fg(patterns, {
82
+ cwd: rootDir,
83
+ ignore: allIgnore,
84
+ dot: true,
85
+ absolute: false,
86
+ onlyFiles: false,
87
+ followSymbolicLinks: false,
88
+ objectMode: true
89
+ });
90
+ const allSkippedSymlinkPaths = symlinkProbeEntries.filter((entry) => entry.dirent.isSymbolicLink()).map((entry) => entry.path).sort(compareScanPaths);
91
+ const skippedSymlinks = allSkippedSymlinkPaths.length;
92
+ const skippedSymlinkFiles = allSkippedSymlinkPaths.slice(0, MAX_SKIPPED_NAMES);
93
+ if (skippedSymlinks > 0) {
94
+ const named = skippedSymlinkFiles.join(", ");
95
+ const more = skippedSymlinks > skippedSymlinkFiles.length ? " (and others)" : "";
96
+ console.warn(
97
+ `[shipguard] Scan INCOMPLETE: ${skippedSymlinks} symlink(s) not followed (privacy moat, incident 3063d8a9) and NOT scanned: ${named}${more}`
98
+ );
99
+ }
77
100
  const total = filePaths.length;
78
101
  const files = [];
79
102
  let skippedTooLarge = 0;
80
103
  const skippedTooLargeFiles = [];
81
104
  let skippedBinary = 0;
105
+ const skippedBinaryFiles = [];
82
106
  let truncated = false;
83
107
  let totalBytes = 0;
84
108
  let processed = 0;
@@ -103,6 +127,9 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
103
127
  const buffer = await readFile(fullPath);
104
128
  if (detectBinary(new Uint8Array(buffer))) {
105
129
  skippedBinary++;
130
+ if (skippedBinaryFiles.length < MAX_SKIPPED_NAMES) {
131
+ skippedBinaryFiles.push(fp);
132
+ }
106
133
  onProgress?.(++processed, total, fp);
107
134
  continue;
108
135
  }
@@ -131,6 +158,9 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
131
158
  skippedTooLarge,
132
159
  skippedTooLargeFiles,
133
160
  skippedBinary,
161
+ skippedBinaryFiles,
162
+ skippedSymlinks,
163
+ skippedSymlinkFiles,
134
164
  truncated,
135
165
  invalidUtf8Files,
136
166
  unreadableFiles
@@ -141,5 +171,6 @@ export {
141
171
  DEFAULT_MAX_FILE_SIZE_BYTES,
142
172
  DEFAULT_MAX_TOTAL_BYTES,
143
173
  DEFAULT_MAX_FILES,
174
+ compareScanPaths,
144
175
  readFiles
145
176
  };