Skip to content

Commit c9360b9

Browse files
committed
improve agent ux, update publish flow
1 parent 3937893 commit c9360b9

File tree

13 files changed

+1114
-272
lines changed

13 files changed

+1114
-272
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ socket-patch 550e8400-e29b-41d4-a716-446655440000
7474

7575
## Commands
7676

77+
All commands support `--json` for structured JSON output and `--cwd <dir>` to set the working directory (default: `.`). Every JSON response includes a `"status"` field (`"success"`, `"error"`, `"no_manifest"`, etc.) for reliable programmatic consumption.
78+
7779
### `get`
7880

7981
Get security patches from Socket API and apply them. Accepts a UUID, CVE ID, GHSA ID, PURL, or package name. The identifier type is auto-detected but can be forced with a flag.
@@ -94,10 +96,11 @@ socket-patch get <identifier> [options]
9496
| `--ghsa` | Force identifier to be treated as a GHSA ID |
9597
| `-p, --package` | Force identifier to be treated as a package name |
9698
| `-y, --yes` | Skip confirmation prompt for multiple patches |
97-
| `--no-apply` | Download patch without applying it |
99+
| `--save-only` | Download patch without applying it (alias: `--no-apply`) |
98100
| `--one-off` | Apply patch immediately without saving to `.socket` folder |
99101
| `-g, --global` | Apply to globally installed packages |
100102
| `--global-prefix <path>` | Custom path to global `node_modules` |
103+
| `--json` | Output results as JSON |
101104
| `--api-token <token>` | Socket API token (overrides `SOCKET_API_TOKEN`) |
102105
| `--api-url <url>` | Socket API URL (overrides `SOCKET_API_URL`) |
103106
| `--cwd <dir>` | Working directory (default: `.`) |
@@ -117,10 +120,13 @@ socket-patch get GHSA-xxxx-yyyy-zzzz
117120
socket-patch get lodash
118121

119122
# Download only, don't apply
120-
socket-patch get CVE-2024-12345 --no-apply
123+
socket-patch get CVE-2024-12345 --save-only
121124

122125
# Apply to global packages
123126
socket-patch get lodash -g
127+
128+
# JSON output for scripting
129+
socket-patch get CVE-2024-12345 --json -y
124130
```
125131

126132
### `scan`
@@ -137,6 +143,7 @@ socket-patch scan [options]
137143
|------|-------------|
138144
| `--org <slug>` | Organization slug |
139145
| `--json` | Output results as JSON |
146+
| `--ecosystems <list>` | Restrict to specific ecosystems (comma-separated: `npm,pypi,cargo`) |
140147
| `-g, --global` | Scan globally installed packages |
141148
| `--global-prefix <path>` | Custom path to global `node_modules` |
142149
| `--batch-size <n>` | Packages per API request (default: `100`) |
@@ -152,6 +159,9 @@ socket-patch scan
152159
# Scan with JSON output
153160
socket-patch scan --json
154161

162+
# Scan only npm packages
163+
socket-patch scan --ecosystems npm
164+
155165
# Scan global packages
156166
socket-patch scan -g
157167
```
@@ -170,11 +180,14 @@ socket-patch apply [options]
170180
|------|-------------|
171181
| `-d, --dry-run` | Verify patches without modifying files |
172182
| `-s, --silent` | Only output errors |
183+
| `-f, --force` | Skip pre-application hash verification (apply even if package version differs) |
173184
| `-m, --manifest-path <path>` | Path to manifest (default: `.socket/manifest.json`) |
174185
| `--offline` | Do not download missing blobs; fail if any are missing |
175186
| `-g, --global` | Apply to globally installed packages |
176187
| `--global-prefix <path>` | Custom path to global `node_modules` |
177188
| `--ecosystems <list>` | Restrict to specific ecosystems (comma-separated, e.g. `npm,pypi`) |
189+
| `--json` | Output results as JSON |
190+
| `-v, --verbose` | Show detailed per-file verification information |
178191
| `--cwd <dir>` | Working directory (default: `.`) |
179192

180193
**Examples:**
@@ -190,6 +203,9 @@ socket-patch apply --ecosystems npm
190203

191204
# Apply in offline mode
192205
socket-patch apply --offline
206+
207+
# JSON output for CI/CD
208+
socket-patch apply --json
193209
```
194210

195211
### `rollback`
@@ -211,6 +227,8 @@ socket-patch rollback [identifier] [options]
211227
| `-g, --global` | Rollback globally installed packages |
212228
| `--global-prefix <path>` | Custom path to global `node_modules` |
213229
| `--ecosystems <list>` | Restrict to specific ecosystems (comma-separated) |
230+
| `--json` | Output results as JSON |
231+
| `-v, --verbose` | Show detailed per-file verification information |
214232
| `--org <slug>` | Organization slug |
215233
| `--api-token <token>` | Socket API token (overrides `SOCKET_API_TOKEN`) |
216234
| `--api-url <url>` | Socket API URL (overrides `SOCKET_API_URL`) |
@@ -229,6 +247,9 @@ socket-patch rollback 550e8400-e29b-41d4-a716-446655440000
229247

230248
# Dry run
231249
socket-patch rollback --dry-run
250+
251+
# JSON output
252+
socket-patch rollback --json
232253
```
233254

234255
### `list`
@@ -290,6 +311,7 @@ socket-patch remove <identifier> [options]
290311
| `--skip-rollback` | Only update manifest, do not restore original files |
291312
| `-g, --global` | Remove from globally installed packages |
292313
| `--global-prefix <path>` | Custom path to global `node_modules` |
314+
| `--json` | Output results as JSON |
293315
| `-m, --manifest-path <path>` | Path to manifest (default: `.socket/manifest.json`) |
294316
| `--cwd <dir>` | Working directory (default: `.`) |
295317

@@ -303,6 +325,9 @@ socket-patch remove 550e8400-e29b-41d4-a716-446655440000
303325

304326
# Remove without rolling back files
305327
socket-patch remove "pkg:npm/lodash@4.17.20" --skip-rollback
328+
329+
# JSON output
330+
socket-patch remove "pkg:npm/lodash@4.17.20" --json
306331
```
307332

308333
### `setup`
@@ -319,6 +344,7 @@ socket-patch setup [options]
319344
|------|-------------|
320345
| `-d, --dry-run` | Preview changes without modifying files |
321346
| `-y, --yes` | Skip confirmation prompt |
347+
| `--json` | Output results as JSON |
322348
| `--cwd <dir>` | Working directory (default: `.`) |
323349

324350
**Examples:**
@@ -331,6 +357,9 @@ socket-patch setup -y
331357

332358
# Preview changes
333359
socket-patch setup --dry-run
360+
361+
# JSON output for scripting
362+
socket-patch setup --json -y
334363
```
335364

336365
### `repair`
@@ -350,6 +379,7 @@ socket-patch repair [options]
350379
| `-d, --dry-run` | Show what would be done without doing it |
351380
| `--offline` | Skip network operations (cleanup only) |
352381
| `--download-only` | Only download missing blobs, do not clean up |
382+
| `--json` | Output results as JSON |
353383
| `-m, --manifest-path <path>` | Path to manifest (default: `.socket/manifest.json`) |
354384
| `--cwd <dir>` | Working directory (default: `.`) |
355385

@@ -363,8 +393,27 @@ socket-patch repair --offline
363393

364394
# Download missing blobs only
365395
socket-patch repair --download-only
396+
397+
# JSON output
398+
socket-patch repair --json
399+
```
400+
401+
## Scripting & CI/CD
402+
403+
All commands support `--json` for machine-readable output. JSON responses always include a `"status"` field for easy error detection:
404+
405+
```bash
406+
# Check for available patches in CI
407+
result=$(socket-patch scan --json --ecosystems npm)
408+
patches=$(echo "$result" | jq '.totalPatches')
409+
410+
# Apply patches and check result
411+
socket-patch apply --json | jq '.status'
412+
# "success", "partial_failure", "no_manifest", or "error"
366413
```
367414

415+
When stdin is not a TTY (e.g., in CI pipelines), interactive prompts auto-proceed instead of blocking. Progress indicators and ANSI colors are automatically suppressed when output is piped.
416+
368417
## Environment Variables
369418

370419
| Variable | Description |

0 commit comments

Comments
 (0)