You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CLI_CONTRACT.md:
* Scan flag table: replace --no-prune row with three new rows —
--prune, --sync, -d/--dry-run. Add a paragraph explaining each
plus the canonical bot-mode invocation.
* JSON output shape: drop the --no-prune-emits-{skipped:true} note.
Clarify that `gc` is omitted ENTIRELY when --prune/--sync isn't
set. Document --dry-run behavior including the explicit
`apply.dryRun: true` marker for bots.
* New "scan — --sync (bot mode)" section with the canonical
`scan --json --sync --yes | jq '{applied, pruned, bytes_freed}'`
recipe.
* New "scan — --dry-run" section explaining that --dry-run is a
no-op without one of the mutating flags.
* Restore the `repair` section's normal heading (drop the
"*(deprecated since v3.0)*" suffix and the deprecation paragraph).
Note that the `gc` visible_alias is now contract-guarded.
* Semver-policy table: drop the GC-default row, add explicit rows
for "flipping --prune to opt-out" and "demoting `gc` from
visible_alias" — both MAJOR.
README.md:
* Restore the `### repair` / `gc` section that was removed during
the deprecation iteration. Wording clarifies that `repair`/`gc` is
the right answer for cleanup-without-apply and points users at
`scan --sync` for the combined workflow.
* `### scan` section: replace --no-prune row with --prune, --sync,
--dry-run, --yes. Bot-mode example becomes `scan --json --sync --yes`
(the user's "one or two flags" target). Add a `scan --json --sync
--yes --dry-run` example.
* `## Scripting & CI/CD`: lead with the new `--sync` recipe piped
through jq into `peter-evans/create-pull-request`. Keep the old
`scan --json --ecosystems npm` read-only example as the second
use case.
Assisted-by: Claude Code:claude-opus-4-7
Copy file name to clipboardExpand all lines: README.md
+62-7Lines changed: 62 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,7 +137,7 @@ socket-patch get CVE-2024-12345 --json -y
137
137
138
138
### `scan`
139
139
140
-
Scan installed packages for available security patches. Since v3.0 `scan` is the single command bots need: it discovers patches, optionally applies them, and garbage-collects orphan blob files plus manifest entries for uninstalled packages.
140
+
Scan installed packages for available security patches. Since v3.0 `scan --sync` is the single command bots need for full auto-update: it discovers patches, applies them, and garbage-collects orphan blob files plus manifest entries for uninstalled packages — all in one invocation.
141
141
142
142
**Usage:**
143
143
```bash
@@ -148,7 +148,9 @@ socket-patch scan [options]
148
148
| Flag | Description |
149
149
|------|-------------|
150
150
|`--apply`| Download and apply selected patches in JSON mode (non-interactive). Without it, `scan --json` is read-only. |
151
-
|`--no-prune`| Disable garbage collection. By default `scan` removes manifest entries for uninstalled packages and orphan blob/diff/package-archive files. |
151
+
|`--prune`| Garbage-collect after the scan: remove manifest entries for uninstalled packages and orphan blob/diff/package-archive files. Off by default. |
152
+
|`--sync`| Sugar for `--apply --prune`. The canonical bot-mode flag. |
153
+
|`-d, --dry-run`| Preview what `--apply`/`--prune`/`--sync` would do without mutating disk. |
152
154
|`--org <slug>`| Organization slug |
153
155
|`--json`| Output results as JSON |
154
156
|`-y, --yes`| Skip confirmation prompts |
@@ -166,14 +168,20 @@ socket-patch scan [options]
166
168
# Scan local project (interactive prompt to apply)
`repair` cleans up the `.socket/` directory without running a scan — useful when you've manually adjusted the manifest, recovered from a partial-failure state, or just want to free space. For the combined workflow (discover + apply + GC in one pass), use `scan --sync --json --yes` instead.
365
+
366
+
**Usage:**
367
+
```bash
368
+
socket-patch repair [options]
369
+
```
370
+
371
+
**Options:**
372
+
| Flag | Description |
373
+
|------|-------------|
374
+
|`-d, --dry-run`| Show what would be done without doing it |
`--apply` opts JSON callers into the full discover → select → apply pipeline. Without it, `scan --json` stays read-only (discovery + `updates` array only). No effect outside `--json` mode — the non-JSON path always prompts the user interactively. Designed for unattended workflows (cron jobs, bots that open PRs).
88
92
89
-
`--apply` opts JSON callers into the full discover → select → apply pipeline. Without it, `scan --json` stays read-only (discovery + `updates` array + `gc` preview only). No effect outside `--json` mode — the non-JSON path always prompts the user interactively. Designed for unattended workflows (cron jobs, bots that open PRs).
93
+
`--prune` opts into garbage collection. When set, `scan` removes manifest entries for packages no longer present in the crawl, then deletes orphan blob, diff, and package-archive files from `.socket/`. Off by default (v3.0) so a temporary uninstall doesn't silently destroy manifest state. Pair with `--apply` (or use `--sync`) for the auto-update workflow.
90
94
91
-
`--no-prune` disables garbage collection. By default (since v3.0) `scan` removes manifest entries for packages no longer present in the crawl and deletes orphan blob, diff, and package-archive files from `.socket/`. Pass `--no-prune` to leave the manifest and `.socket/` directory untouched.
95
+
`--sync` is sugar for `--apply --prune` — the canonical single-flag bot invocation. `scan --json --sync --yes` discovers, applies, and reconciles state in one pass.
96
+
97
+
`--dry-run` (`-d`) previews what `--apply` / `--prune` / `--sync` would do without mutating disk. In JSON mode, `apply.patches[*]` is populated with would-be actions (computed via `decide_patch_action` against the current manifest) and `gc.prunable*` / `gc.orphan*` fields report counts via the cleanup helpers' built-in dry-run mode. No effect without at least one of `--apply`, `--prune`, or `--sync`.
`scan` now performs garbage collection by default (manifest pruning + orphan file cleanup); prefer `scan` or `scan --no-prune`. `repair` and its `gc` alias remain available for direct invocation but no longer appear in `socket-patch --help`. The subcommand itself is hidden via `clap`'s `hide = true`, and `gc`is demoted from `visible_alias` to `alias`. **Removing `repair` entirely or unhiding it requires a MAJOR bump.**
132
+
`repair` (alias `gc`) is a first-class command for cleaning up the `.socket/` directory without running a scan. For the combined discover-and-apply workflow with GC, use `scan --sync --json --yes`; for cleanup alone, use `repair` (or `gc`) directly. The `gc`visible alias is part of the contract — removing or demoting it is a MAJOR bump.
127
133
128
134
| Long | Short | Default | Type |
129
135
|---|---|---|---|
@@ -241,24 +247,17 @@ When `--json` is set, commands print a single JSON object to stdout. The schemas
The `updates` array lists PURLs where the newest available patch UUID differs from the one currently recorded in `.socket/manifest.json`. Bots use this to drive "what would change" summaries without mutating anything.
256
255
257
-
The `gc` sub-object in read-only mode is a *preview*: it reports what `scan --apply`*would*prune and clean up, without touching disk. When `scan` runs with no crawl results (e.g., empty project, `node_modules` missing), GC is intentionally skipped and `gc` is emitted as `{ "skipped": true }` to prevent destroying a manifest the user may still want.
256
+
**The `gc` sub-object is omitted entirely when `--prune` (or `--sync`) is not set.** GC information is opt-in — `scan --json` alone is purely about patch discovery and update detection.
258
257
259
258
### `scan` — `--apply` mode
260
259
261
-
When invoked as `scan --json --apply`, the discovery object above is augmented with a top-level `apply` sub-object reporting per-patch outcomes from the download + manifest write, and the `gc` sub-object switches from preview to actual results:
260
+
When invoked as `scan --json --apply`, the discovery object above is augmented with a top-level `apply` sub-object reporting per-patch outcomes from the download + manifest write. The `gc` sub-object is added only when `--prune` (or `--sync`, which implies it) is also set:
262
261
263
262
```json
264
263
{
@@ -290,7 +289,25 @@ When invoked as `scan --json --apply`, the discovery object above is augmented w
290
289
}
291
290
```
292
291
293
-
With `--no-prune`, the `gc` sub-object is emitted as `{ "skipped": true }` in both read-only and `--apply` modes. GC field names differ between preview (`prunable*`/`orphan*`/`bytesReclaimable`) and apply (`pruned*`/`removed*`/`bytesFreed`) modes — bots should check `gc.prunedManifestEntries` vs `gc.prunableManifestEntries` accordingly.
292
+
Without `--prune` or `--sync`, the `gc` field is **omitted entirely** from the output. When `--prune` is set without `--dry-run`, `gc` uses the apply-mode field names (`prunedManifestEntries`, `removedBlobs`, `removedDiffArchives`, `removedPackageArchives`, `bytesFreed`). With `--dry-run`, it uses preview-mode field names (`prunableManifestEntries`, `orphanBlobs`, `orphanDiffArchives`, `orphanPackageArchives`, `bytesReclaimable`) and nothing is mutated. Bots should branch on which field set is present, not assume a single shape.
293
+
294
+
### `scan` — `--sync` (bot mode)
295
+
296
+
`scan --json --sync --yes` is sugar for `scan --json --apply --prune --yes` — the canonical single-command auto-update workflow. Output is the full discovery + `apply` + `gc` shape above. Pipe it into PR-creation tooling:
Exit `0` on success, `1` if any `apply.patches[*].action == "failed"` (top-level `status` becomes `"partial_failure"`).
307
+
308
+
### `scan` — `--dry-run`
309
+
310
+
When combined with `--apply`, `--prune`, or `--sync`, `--dry-run` (`-d`) populates `apply.patches[*]` and `gc.prunable*` / `gc.orphan*` fields with the *would-be* actions without touching disk. The `apply` sub-object in dry-run mode includes a `"dryRun": true` field for bots that need an explicit signal. Without one of the mutating flags, `--dry-run` is a no-op (discovery is already non-mutating).
294
311
295
312
Per-patch `action` vocabulary is stable:
296
313
@@ -327,7 +344,8 @@ Versioning lives in **`Cargo.toml`** at the workspace root (`version = "..."`) a
327
344
| Rename a JSON output key or change a `status` string |**MAJOR**|
328
345
| Remove a JSON output key |**MAJOR**|
329
346
| Rename or remove a per-patch `action` value (`added`/`updated`/`skipped`/`failed`) |**MAJOR**|
330
-
| Change `scan`'s default behavior (e.g. pruning, GC, apply) |**MAJOR** — done once in v3.0; future flips also MAJOR. |
347
+
| Change `scan`'s default behavior (e.g. flipping `--prune` to opt-out, or making `--apply` default) |**MAJOR**|
348
+
| Demote `repair`'s `gc` from `visible_alias` to hidden, or remove the `repair` subcommand |**MAJOR**|
0 commit comments