Skip to content

feat(installer): fetch resq-cli binary + per-shell completions (Stage 2)#16

Merged
WomB0ComB0 merged 2 commits into
mainfrom
feat/installer-fetches-resq-cli
Apr 19, 2026
Merged

feat(installer): fetch resq-cli binary + per-shell completions (Stage 2)#16
WomB0ComB0 merged 2 commits into
mainfrom
feat/installer-fetches-resq-cli

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

@WomB0ComB0 WomB0ComB0 commented Apr 19, 2026

Summary

Stage 2 of the CLI ergonomics work. After this PR, sh install.sh finishes the job — you get the `resq` binary on disk and its shell completions wired up, not just a cloned repo.

What the installer now does (in order):

  1. Map $OS / $ARCH → Rust target triple (Linux x86_64/aarch64, macOS x86_64/arm64).
  2. gh release list → find the latest resq-cli-v* tag in resq-software/crates.
  3. gh release download the matching .tar.gz + SHA256SUMS.
  4. sha256sum -cfailed checksum aborts with a warning, never silently installs an unverified binary.
  5. Extract → install -m 0755 → $RESQ_BIN_DIR/resq (default ~/.local/bin/resq).
  6. Detect $SHELL, generate completions via resq completions <shell>, write to the conventional user-local path:
    • bash → ~/.local/share/bash-completion/completions/resq
    • zsh → ~/.local/share/zsh/site-functions/_resq (+ zsh fpath hint)
    • fish → ~/.config/fish/completions/resq.fish
    • other → hint to run resq completions <shell> manually.
  7. Warn if ~/.local/bin isn't already in $PATH.

Idempotent: if `resq --version` already matches the latest release tag, we skip download and refresh completions. Opt out entirely with SKIP_RESQ_CLI=1. Custom install prefix via RESQ_BIN_DIR=/opt/resq/bin.

Also improved post_clone_setup's silent `nix develop` — Stage 1 audit flagged the 2–5 minute freeze with only a vague "a few minutes" banner. Now we state the expected download size (500 MB – 2 GB) and time (2–5 min) up front, and print actual elapsed seconds on success.

Test plan

  • sh -n install.sh, bash -n install.sh, shellcheck install.sh — all clean
  • gh release list --repo resq-software/crates returns resq-cli-v0.2.6 and release has all 5 expected assets (4 tar.gz + SHA256SUMS)
  • End-to-end: fresh VM / container, `REPO=crates YES=1 sh install.sh` → resq --version on PATH, tab-completion works in the user's shell
  • SKIP_RESQ_CLI=1 sh install.sh — binary install skipped, rest of the flow unchanged
  • Re-run (idempotency): second pass prints resq X.Y.Z already installed and refreshes completions

Not in this PR (Stage 3 / follow-ups)

  • install.ps1 mirror (separate follow-up — needs Expand-Archive + Invoke-WebRequest + shell-aware completion paths on Windows).
  • Runtime repo-menu refresh via gh api /orgs/resq-software/repos — deferred; the 8-entry hardcoded menu is a small surface.
  • Stage 3 (flat-surface → resq scan / resq tui groups) still pending.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Automated installation of the resq CLI tool with automatic OS and architecture detection.
    • Automatic generation and installation of shell completions for bash, zsh, and fish shells.
    • Added PATH verification warnings for tool accessibility.
  • Chores

    • Enhanced setup script with improved logging and status feedback.
    • Installation process is now idempotent to prevent unnecessary re-downloads.

Until now, install.sh cloned the target repo and set up the nix shell but
never actually installed the resq binary that the whole toolchain is named
after. Users had to remember `cargo install resq-cli` or `gh release download`
separately. Stage 2 closes that gap.

After post_clone_setup, the installer now:

- Detects platform (Linux x86_64/aarch64, macOS x86_64/arm64) and maps to
  the right Rust target triple.
- Queries `gh release list` for the latest `resq-cli-v*` tag in
  resq-software/crates (Windows is skipped; install.ps1 will handle it
  separately later).
- Downloads the matching tar.gz and SHA256SUMS via `gh release download`.
- Verifies the checksum with `sha256sum -c` — a failed checksum aborts
  the install with a warning, not silently.
- Drops the verified binary at $RESQ_BIN_DIR/resq (default ~/.local/bin/resq,
  mode 0755).
- Detects the user's $SHELL (bash/zsh/fish) and writes the generated
  completion script to the conventional user-local path. Other shells get
  a hint to run `resq completions <shell>` manually.
- Warns if ~/.local/bin isn't already on $PATH.

Idempotent: if `resq --version` already matches the latest release tag, we
skip the download and just refresh completions. Opt out entirely with
`SKIP_RESQ_CLI=1`.

Also improved post_clone_setup's nix develop step: the previous "a few
minutes" message was too vague to be useful. Now we state the expected
download size (500 MB–2 GB) and time (2–5 min) up front, and report the
actual elapsed seconds when it succeeds. Still no real-time progress —
that would need tee-ing the nix log — but expectation-setting is free.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The install.sh script enhances post_clone_setup() to log successful nix develop execution with timing information and improves error handling. Two new public functions—install_resq_cli() and install_resq_completions()—are introduced to download, verify, and install the resq-cli binary from GitHub releases along with shell completions, invoked from the main installation flow.

Changes

Cohort / File(s) Summary
Resq CLI Installation
install.sh
Added install_resq_cli() to download and install resq-cli binary from GitHub releases with SHA256 verification, OS/arch detection, and idempotent binary matching. Added install_resq_completions() to generate and install shell completions for bash/zsh/fish. Modified post_clone_setup() to log timestamps and elapsed time for successful nix develop execution. Updated main() control flow to invoke install_resq_cli after post_clone_setup.

Sequence Diagram

sequenceDiagram
    participant Main as main()
    participant InstallCLI as install_resq_cli()
    participant GH as GitHub API (gh)
    participant SHA as SHA256 Verify
    participant Archive as Extract & Locate
    participant Completions as install_resq_completions()
    participant Shell as Shell Completion Files

    Main->>InstallCLI: call install_resq_cli
    InstallCLI->>InstallCLI: detect OS/arch triple
    InstallCLI->>GH: gh release list (query resq-cli releases)
    GH-->>InstallCLI: return latest release tag
    InstallCLI->>InstallCLI: check existing resq binary version
    alt Binary matches expected version
        InstallCLI-->>Main: return (idempotent skip)
    else Binary missing or outdated
        InstallCLI->>GH: download resq-cli-{tag}-{triple}.tar.gz
        InstallCLI->>GH: download SHA256SUMS
        GH-->>InstallCLI: provide assets
        InstallCLI->>SHA: verify SHA256 of downloaded archive
        alt Verification passes
            InstallCLI->>Archive: extract tar.gz
            Archive-->>InstallCLI: locate resq binary
            InstallCLI->>InstallCLI: install to RESQ_BIN_DIR
            InstallCLI->>Completions: call install_resq_completions
            Completions->>Completions: detect current shell (bash/zsh/fish)
            Completions->>Shell: generate and install completions
            Shell-->>Completions: return
            Completions-->>InstallCLI: return
        else Verification fails
            InstallCLI-->>Main: warn and exit
        end
    end
    InstallCLI-->>Main: return
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop hop, the resq arrives with a gleam!
GitHub releases downloaded in a dream,
SHA sums verified, true and neat,
Shell completions make the setup complete!
Installation flows smooth as a rabbit's feet. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding resq-cli binary fetch and per-shell completions functionality to the installer as Stage 2.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/installer-fetches-resq-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the install.sh script by adding automated installation of the resq CLI binary and its shell completions. It also improves the Nix environment setup by providing more detailed progress information and timing. Feedback focuses on improving the portability of the checksum verification for macOS and making the binary extraction process more robust against archive structure changes.

Comment thread install.sh Outdated
Comment thread install.sh Outdated
Addresses gemini-code-assist review on PR #16.

- sha256sum is GNU-only; macOS ships `shasum -a 256` instead. Use
  sha256sum when available, fall back to shasum. Also drop the
  `--quiet` flag (GNU-only) — stdout already redirects to /dev/null.
- Stop relying on the hardcoded `resq-cli-<tag>-<triple>/resq`
  staging-dir layout. `find` the extracted binary instead; matches
  the pattern already used in scripts/install-resq.sh and stays
  resilient if release.yml ever changes the archive's inner dir name.
@WomB0ComB0
Copy link
Copy Markdown
Member Author

Resolved both gemini review points:

  • macOS portabilitysha256sum isn't on macOS. Prefer sha256sum when available, fall back to shasum -a 256 -c. Dropped the GNU-only --quiet flag (stdout already suppressed).
  • Archive layout robustness — replaced the hardcoded resq-cli-${tag}-${triple}/resq path with find "$_tmp" -type f -name resq | head -n 1. Matches the existing scripts/install-resq.sh pattern and survives staging-dir renames in release.yml.

sh -n / bash -n / shellcheck all still clean.

@WomB0ComB0 WomB0ComB0 merged commit 7afdbff into main Apr 19, 2026
15 of 16 checks passed
@WomB0ComB0 WomB0ComB0 deleted the feat/installer-fetches-resq-cli branch April 19, 2026 04:28
WomB0ComB0 added a commit that referenced this pull request Apr 19, 2026
PowerShell parity for install.sh's Stage 2 work (#16).
Before this, install.ps1 cloned the repo and set up the nix/WSL environment
but never installed the resq binary — Windows users had to remember
`gh release download` by hand.

Adds two new functions:

- Install-ResqCli: maps $IsWindows / $IsMacOS / $IsLinux + $Arch to the
  right Rust target triple, picks .zip on Windows or .tar.gz on Unix,
  downloads the archive + SHA256SUMS via `gh release download`, verifies
  the checksum with Get-FileHash, extracts (Expand-Archive for zip,
  tar.exe for tar.gz — both native on Win10+ and all Unix hosts),
  locates the binary via Get-ChildItem -Recurse (matches install.sh's
  `find` pattern), and installs to $env:RESQ_BIN_DIR (defaults:
  %LOCALAPPDATA%\Programs\resq\bin on Windows, ~/.local/bin on Unix).
  Chmod 0755 on Unix, Copy-Item on Windows. Idempotent via
  `resq --version` match; skippable with $env:SKIP_RESQ_CLI=1.
  PATH hint if the bin dir isn't on PATH.

- Install-ResqCompletions: emits `resq completions powershell` to
  $(Split-Path $PROFILE -Parent)\Completions\resq.ps1 and tells the
  user to source it from $PROFILE if they haven't already.

Also aligns Initialize-Repo's nix-develop progress messaging with the
sh version: set expectations for download size and time upfront, and
print actual elapsed seconds when the build succeeds.

Wiring: Main now calls Install-ResqCli between Initialize-Repo and
Show-RepoInfo, matching install.sh's main().
WomB0ComB0 added a commit that referenced this pull request Apr 19, 2026
…#17)

* feat(installer): install.ps1 Stage 2 mirror — binary + PS completions

PowerShell parity for install.sh's Stage 2 work (#16).
Before this, install.ps1 cloned the repo and set up the nix/WSL environment
but never installed the resq binary — Windows users had to remember
`gh release download` by hand.

Adds two new functions:

- Install-ResqCli: maps $IsWindows / $IsMacOS / $IsLinux + $Arch to the
  right Rust target triple, picks .zip on Windows or .tar.gz on Unix,
  downloads the archive + SHA256SUMS via `gh release download`, verifies
  the checksum with Get-FileHash, extracts (Expand-Archive for zip,
  tar.exe for tar.gz — both native on Win10+ and all Unix hosts),
  locates the binary via Get-ChildItem -Recurse (matches install.sh's
  `find` pattern), and installs to $env:RESQ_BIN_DIR (defaults:
  %LOCALAPPDATA%\Programs\resq\bin on Windows, ~/.local/bin on Unix).
  Chmod 0755 on Unix, Copy-Item on Windows. Idempotent via
  `resq --version` match; skippable with $env:SKIP_RESQ_CLI=1.
  PATH hint if the bin dir isn't on PATH.

- Install-ResqCompletions: emits `resq completions powershell` to
  $(Split-Path $PROFILE -Parent)\Completions\resq.ps1 and tells the
  user to source it from $PROFILE if they haven't already.

Also aligns Initialize-Repo's nix-develop progress messaging with the
sh version: set expectations for download size and time upfront, and
print actual elapsed seconds when the build succeeds.

Wiring: Main now calls Install-ResqCli between Initialize-Repo and
Show-RepoInfo, matching install.sh's main().

* fix(installer): resolve PR#17 review — Windows arch guard + native exit check

Addresses gemini-code-assist review:

- Install-ResqCli: the Windows branch assumed x86_64 unconditionally.
  On 32-bit Windows ($script:Arch = 'x86') we'd have downloaded the
  x86_64 asset and failed later at checksum-miss / run time. Bail up
  front with a clear warning when the arch isn't x64. Matches the
  validation pattern already used for macOS / Linux.
- Install-ResqCompletions: `& \$BinPath completions powershell` is
  native exec, which doesn't throw on non-zero exit (even with
  ErrorActionPreference=Stop) — so a corrupt or incompatible binary
  could silently leave an empty completions file on disk. Check
  \$LASTEXITCODE explicitly and throw; the catch now also deletes the
  partial file and surfaces the underlying error in the warning.
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