Skip to content

feat: interactive prompts and smart patch selection#37

Merged
mikolalysenko merged 2 commits intomainfrom
feat/interactive-prompts
Mar 6, 2026
Merged

feat: interactive prompts and smart patch selection#37
mikolalysenko merged 2 commits intomainfrom
feat/interactive-prompts

Conversation

@mikolalysenko
Copy link
Contributor

Summary

  • Shared prompt utilities (output.rs): confirm() for Y/n prompts (default YES), select_one() for dialoguer-based selection, both write to stderr to avoid interfering with JSON stdout
  • Smart patch selection (get.rs): Paid users auto-select best paid patch per PURL; free users with multiple patches get interactive selection; JSON mode returns selection_required error with full vulnerability details (severity, CVEs, summaries)
  • Scan download flow (scan.rs): After displaying the scan table, fetches full patch details, shows a per-patch summary with severity/CVEs/descriptions, then confirms before downloading. Adds -y/--yes flag and [UPDATE] markers for packages with newer patches
  • Remove confirmation (remove.rs): Shows what will be removed (PURL, UUID, file count) and confirms before rollback. Adds -y/--yes flag
  • Extracted download_and_apply_patches(): Shared download logic used by both get and scan, with update detection ([update] log when replacing existing patches)

Prompt behavior by mode

Scenario Interactive -y flag JSON mode
get: patches found Y/n confirm (default Y) Auto-proceed No prompt
get: multiple patches, paid Auto-select best, Y/n Auto-proceed No prompt, auto-select
get: multiple patches, free dialoguer select, Y/n Auto-select first selection_required error with options
scan: patches found Summary + Y/n download Auto-download JSON output only
remove Details + Y/n confirm Auto-proceed No prompt

Test plan

  • cargo build — clean, no warnings
  • cargo test --features cargo — all 260 tests pass
  • Manual: socket-patch scan — see table + patch summary + Y/n download prompt
  • Manual: socket-patch scan --json — no prompt, JSON output only
  • Manual: socket-patch scan -y — auto-downloads without prompt
  • Manual: socket-patch get <purl> — see Y/n prompt, default yes on enter
  • Manual: socket-patch get <purl> --json — no prompt
  • Manual: socket-patch remove <purl> — see details + confirmation
  • Manual: socket-patch remove <purl> -y — auto-proceeds

🤖 Generated with Claude Code

mikolalysenko and others added 2 commits March 6, 2026 12:13
- Add shared confirm() and select_one() prompt utilities to output.rs
- Smart patch selection: paid users auto-select best paid patch per PURL,
  free users with multiple patches get dialoguer interactive selection
- Default-YES confirmation prompts (Y/n) for get, scan, and remove
- Add -y/--yes flag to scan and remove commands to skip prompts
- JSON mode never prompts; returns selection_required error with full
  vulnerability details when explicit selection is needed
- Scan now shows detailed patch summary (severity, CVEs, descriptions)
  before confirming download
- Remove shows what will be removed before confirming rollback
- Extract download_and_apply_patches() shared between get and scan
- Add patch update detection in scan table and download flow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use is_none_or instead of map_or(true, ...)
- Use .values() instead of destructuring with unused key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikolalysenko mikolalysenko merged commit 4271625 into main Mar 6, 2026
7 checks passed
@mikolalysenko mikolalysenko deleted the feat/interactive-prompts branch March 6, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant