Skip to content
Back to search

hey

HEY integration for Claude Code. Read email, manage todos, track time.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/basecamp/hey-cli with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/basecamp/hey-cli'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/basecamp--hey-cli/badge.svg)](/listings/basecamp--hey-cli)

HTML

<a href="/listings/basecamp--hey-cli"><img src="/api/listings/basecamp--hey-cli/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

**mise**

mise use -g github:basecamp/hey-cli

**Omarchy**

omarchy-mise-install github:basecamp/hey-cli hey

**macOS / Linux / WSL2**

curl -fsSL https://hey.com/install-cli | bash

**Windows (PowerShell)**

irm https://hey.com/install-cli.ps1 | iex

Homebrew, Scoop, Nix, packages and source builds: [docs/install.md](docs/install.md).

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/plugin.json · Manifest · 12 lines
  1. {
  2. "name": "hey",
  3. "version": "1.13.1",
  4. "description": "HEY integration for Claude Code. Read email, manage todos, track time.",
  5. "author": {
  6. "name": "37signals",
  7. "email": "support@37signals.com"
  8. },
  9. "homepage": "https://github.com/basecamp/hey-cli",
  10. "repository": "https://github.com/basecamp/hey-cli",
  11. "license": "MIT"
  12. }
README.md · README · 119 lines · 2 findings marked
  1. # HEY! It's the command-line interface!
  2. ```
  3. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  4. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡿⠏⠻⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  5. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣶⣶⣤⠀⠀⠀⣿⠃⠀⠀⠘⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  6. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⠉⠹⣷⣄⠀⣿⡀⠀⠀⠀⠈⢿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣶⣶⣶⣶⣶⠀⠀⠀⠀⠀⠀⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⡀⠀⠀⠀⠀⢠⣶⣶⣶⣶⣶⠀⠀⠀⠀⠀
  7. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⣿⡆⠀⠘⣿⣦⣿⡇⠀⠀⠀⠀⠘⣿⡆⠀⠀⢀⣀⣀⣀⡀⠀⠸⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⣾⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀
  8. ⠀⠀⠀⠀⠀⠀⠀⠀⣾⡿⣷⣄⢻⣧⠀⠀⠈⢿⣿⣷⡆⠀⠀⠀⠀⢸⣿⣠⣶⠿⠛⠛⠛⣿⣆⠀⢹⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⡏⠉⠉⠉⠉⠉⠉⠙⠻⣿⣿⣿⣿⣆⠀⠀⣸⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀
  9. ⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠘⢿⣾⣿⡆⠀⠀⠈⢿⣿⣧⠀⠀⠀⠀⠀⣿⣿⠁⠀⠀⠀⠀⢸⣿⠀⠀⣿⣿⣿⣿⣄⣀⣀⣀⣀⣠⣿⣿⣿⣿⣿⣧⣀⣀⣀⣀⡀⠀⠀⠀⢹⣿⣿⣿⣿⡄⢰⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀
  10. ⠀⠀⠀⠀⠀⠀⠀⠀⢸⣷⠀⠀⠻⣿⣿⡄⠀⠀⠈⢿⣿⡆⠀⠀⠀⢸⣿⣿⠀⠀⠀⠀⠀⢸⣿⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⢻⣿⣿⣿⣷⣿⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀
  11. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣇⠀⠀⠘⢿⣷⡀⠀⠀⠘⠻⣿⡀⠀⠀⣿⡏⣿⡇⠀⠀⠀⠀⢸⣿⠀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀
  12. ⠀⠀⠀⠀⠀⠀⣾⡿⢿⣾⣿⣆⠀⠀⠈⢻⣷⡀⠀⠀⠀⠉⠀⠀⢀⣿⠃⢹⣧⠀⠀⠀⠀⣿⡇⠀⢸⣿⣿⣿⣿⠁⠀⠀⠀⠀⠈⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  13. ⠀⠀⠀⠀⠀⠀⢹⣧⠀⠙⢿⣿⣆⠀⠀⠀⠹⠷⠀⠀⠀⠀⠀⠀⢸⣿⠀⢸⣿⠀⠀⠀⢸⣿⠀⠀⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣽⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  14. ⠀⠀⠀⠀⠀⠀⠀⢿⣧⠀⠀⠙⢿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⢸⣿⠀⠀⢀⣿⠇⠀⢸⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  15. ⠀⠀⠀⠀⠀⠀⠀⠈⢻⣷⡀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣧⣾⡏⠀⠀⣼⡟⠀⠀⠸⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⢻⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  16. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⢿⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  17. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⣷⣦⣄⣀⡀⠀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  18. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⠛⠻⠟⠛⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  19. ```
  20. A CLI and TUI for HEY: your email and calendar, in the terminal and in your coding agent's hands.
  21. ## Install
  22. **mise**
  23. ```bash
  24. mise use -g github:basecamp/hey-cli
  25. ```
  26. **Omarchy**
  27. ```bash
  28. omarchy-mise-install github:basecamp/hey-cli hey
  29. ```
  30. **macOS / Linux / WSL2**
  31. ```bash
  32. curl -fsSL https://hey.com/install-cli | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 41 on GitHub
  33. ```
  34. **Windows (PowerShell)**
  35. ```powershell
  36. irm https://hey.com/install-cli.ps1 | iex
  37. ```
  38. Homebrew, Scoop, Nix, packages and source builds: [docs/install.md](docs/install.md).
  39. ## Getting started
  40. ```bash
  41. hey # sign in with your browser and connect your coding agents
  42. hey tui # open the app
  43. ```
  44. The app has Mail, Contacts, Calendar and Journal, with HEY's own keyboard shortcuts.
  45. Press `?` to see them. It follows HEY live: a thread you archive on your phone leaves the
  46. screen a moment later.
  47. ## Using the CLI
  48. ```bash
  49. hey box view imbox # threads in a box
  50. hey thread read 12345 # a whole thread, as Markdown
  51. hey reply 12345 -m "Friday works for me."
  52. hey compose --to alice@example.com --subject "Lunch?" -m "Thursday at noon?"
  53. hey search --from jane@example.com --date last_30_days
  54. hey screener list # first-time senders waiting on you
  55. hey event add "Design review" --starts-on 2026-09-02 --start-time 14:00
  56. hey watch --box imbox --events new # a line of JSON for every new email, as it lands
  57. ```
  58. Every command explains itself with `--help`. At a terminal the output is made for reading.
  59. Piped, a command that returns data writes JSON, and `--jq` filters it without a separate
  60. `jq`:
  61. ```bash
  62. hey box view imbox --jq '.data.postings[] | {topic_id, subject}'
  63. hey label view 789 --ids-only # one ID per line, for xargs
  64. ```
  65. ## Coding agents
  66. The setup wizard connects the agents it finds. To do it yourself:
  67. ```bash
  68. hey setup claude # skill + the hey@37signals plugin for Claude Code
  69. hey setup codex # skill for Codex
  70. hey auth login --mcp && claude mcp add hey -- hey mcp # HEY as MCP tools, on hey mcp's own sign-in
  71. ```
  72. `hey mcp` saves drafts, and sends one only when you confirm that email in your MCP client.
  73. ## Docs
  74. - [docs/install.md](docs/install.md): installing, upgrading, completions, Windows
  75. - [docs/tui.md](docs/tui.md): the app and its keys
  76. - [docs/cli.md](docs/cli.md): every command, the output formats, and `hey watch`
  77. - [docs/agents.md](docs/agents.md): the skill, the plugin and the MCP server
  78. - [docs/omarchy.md](docs/omarchy.md): the Omarchy integration
  79. Something wrong? `hey doctor` checks the install, sign-in and agent setup.
  80. ## Development
  81. ```bash
  82. make build # build ./bin/hey
  83. make test # run tests
  84. make lint # run golangci-lint
  85. ```
  86. [CONTRIBUTING.md](CONTRIBUTING.md) has the rest. [STYLE.md](STYLE.md) is the Go style.
  87. ## License
  88. MIT. See [LICENSE.md](LICENSE.md).
scripts/install.ps1 · Bundled script · 463 lines · 2 findings marked
  1. # The documented install path is `irm ... | iex`, and Invoke-Expression
    • Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
    • Line 1 on GitHub
  2. # evaluates this file in the caller's scope. The invoked script block below
  3. # gives the installer its own scope, so $ErrorActionPreference and the helper
  4. # functions do not leak into (or clobber) the interactive session. The body
  5. # stays unindented: the here-strings' closing "@ must sit at column zero.
  6. & {
  7. $ErrorActionPreference = 'Stop'
  8. try {
  9. [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
  10. } catch {
  11. # Ignore when the runtime manages TLS defaults.
  12. }
  13. # Environment options:
  14. # HEY_VERSION Specific version to install (default: latest)
  15. # HEY_BIN_DIR Where to install the binary
  16. # HEY_SKIP_SETUP Set to 1 to skip the interactive setup wizard (still runs
  17. # `hey setup agents` to install the agent skill and connect
  18. # coding agents without prompting)
  19. # HEY_SETUP_AGENT Which coding agent(s) `setup agents` connects:
  20. # claude | codex | all | none (default: auto-detect)
  21. #
  22. # This file must stay pure ASCII: the release pipeline stages and
  23. # Authenticode-signs a CRLF copy of it, and Windows PowerShell 5.1 decodes a
  24. # BOM-less file as Windows-1252 while jsign assumes UTF-8, so any byte above
  25. # 0x7F makes the two digests disagree (HashMismatch).
  26. $Repo = 'basecamp/hey-cli'
  27. $Version = $env:HEY_VERSION
  28. $BinDir = $env:HEY_BIN_DIR
  29. $SkipSetup = $env:HEY_SKIP_SETUP
  30. function Step([string]$Message) {
  31. Write-Host " -> $Message"
  32. }
  33. function Info([string]$Message) {
  34. Write-Host " + $Message" -ForegroundColor Green
  35. }
  36. function Fail([string]$Message) {
  37. throw $Message
  38. }
  39. function Get-PlatformArch {
  40. $arch = $env:PROCESSOR_ARCHITECTURE
  41. if ($env:PROCESSOR_ARCHITEW6432) {
  42. $arch = $env:PROCESSOR_ARCHITEW6432
  43. }
  44. switch -Regex ($arch) {
  45. '^(AMD64|x86_64)$' { return 'amd64' }
  46. '^ARM64$' { return 'arm64' }
  47. default { Fail "Unsupported Windows architecture: $arch" }
  48. }
  49. }
  50. function Get-LatestVersion {
  51. Step 'Resolving latest release version...'
  52. # Follow the releases/latest redirect first to avoid GitHub API rate limits.
  53. # -MaximumRedirection 0 turns the expected 302 into a terminating error, so
  54. # we read Location off the caught response. Headers.Location is Uri on
  55. # PowerShell Core and string on Windows PowerShell 5.1, so coerce to string.
  56. $location = $null
  57. try {
  58. $response = Invoke-WebRequest -MaximumRedirection 0 -UseBasicParsing `
  59. -Headers @{ 'User-Agent' = 'hey-cli-installer' } `
  60. -Uri "https://github.com/$Repo/releases/latest" -ErrorAction Stop
  61. $location = $response.Headers.Location
  62. } catch {
  63. if ($_.Exception.Response) {
  64. $location = $_.Exception.Response.Headers.Location
  65. if (-not $location) {
  66. $location = $_.Exception.Response.Headers['Location']
  67. }
  68. }
  69. }
  70. if ($location) {
  71. $tag = ([string]$location).TrimEnd('/').Split('/')[-1]
  72. $candidate = $tag.TrimStart('v')
  73. if ($candidate -match '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$') {
  74. return $candidate
  75. }
  76. }
  77. # Fall back to the GitHub API if the redirect path didn't yield a semver tag.
  78. $release = Invoke-RestMethod -ErrorAction Stop `
  79. -Headers @{ 'User-Agent' = 'hey-cli-installer' } `
  80. -Uri "https://api.github.com/repos/$Repo/releases/latest"
  81. if (-not $release.tag_name) {
  82. Fail 'Could not determine latest release version from GitHub.'
  83. }
  84. return $release.tag_name.TrimStart('v')
  85. }
  86. function Download-File([string]$Url, [string]$Destination) {
  87. # -UseBasicParsing avoids initializing IE's MSHTML parser on Windows
  88. # PowerShell 5.1 -- required on Server Core and locked-down installs.
  89. # No-op on PowerShell 6+, where basic parsing is the only mode.
  90. Invoke-WebRequest -UseBasicParsing -ErrorAction Stop `
  91. -Headers @{ 'User-Agent' = 'hey-cli-installer' } `
  92. -Uri $Url -OutFile $Destination
  93. }
  94. function Verify-Checksum([string]$ChecksumsPath, [string]$ArchivePath, [string]$ArchiveName) {
  95. $expected = $null
  96. foreach ($line in Get-Content $ChecksumsPath) {
  97. if ($line -match '^(?<hash>[0-9a-fA-F]{64})\s+\*?(?<name>.+)$') {
  98. if ($Matches.name -eq $ArchiveName) {
  99. $expected = $Matches.hash.ToLowerInvariant()
  100. break
  101. }
  102. }
  103. }
  104. if (-not $expected) {
  105. Fail "Could not find checksum entry for $ArchiveName"
  106. }
  107. $actual = (Get-FileHash -Algorithm SHA256 -Path $ArchivePath).Hash.ToLowerInvariant()
  108. if ($actual -ne $expected) {
  109. Fail "Checksum verification failed for $ArchiveName"
  110. }
  111. Info 'Checksum verified'
  112. }
  113. # Get-CosignBundleSupport decides how to verify the release's Sigstore bundle,
  114. # which is the new (protobuf, v0.3+json) format:
  115. # v3+ -> new-format parsing is the default; no extra flag ('')
  116. # v2.6 - v2.x -> needs '--new-bundle-format=true' (v2.x defaults it to false)
  117. # < v2.6 / unparseable -> $null: cannot verify (v2.4 chokes on the bundle's
  118. # tlog key type, v2.2 lacks the flag); caller warns and skips
  119. function Get-CosignBundleSupport {
  120. try { $versionOutput = & cosign version 2>$null } catch { return $null }
  121. foreach ($line in @($versionOutput)) {
  122. if ("$line" -match 'GitVersion:\s*v?(\d+)\.(\d+)\.') {
  123. $major = [int]$Matches[1]
  124. $minor = [int]$Matches[2]
  125. if ($major -ge 3) { return '' }
  126. if ($major -eq 2 -and $minor -ge 6) { return '--new-bundle-format=true' }
  127. return $null
  128. }
  129. }
  130. return $null
  131. }
  132. function Verify-CosignSignature([string]$Version, [string]$BaseUrl, [string]$TmpDir) {
  133. if (-not (Get-Command cosign -ErrorAction SilentlyContinue)) {
  134. return
  135. }
  136. $bundleFlag = Get-CosignBundleSupport
  137. if ($null -eq $bundleFlag) {
  138. Step "Skipping signature verification: this cosign can't verify the release bundle format (need cosign >= 2.6)"
  139. return
  140. }
  141. Step 'Verifying cosign signature...'
  142. $bundlePath = Join-Path $TmpDir 'checksums.txt.bundle'
  143. $checksumsPath = Join-Path $TmpDir 'checksums.txt'
  144. Download-File -Url "$BaseUrl/checksums.txt.bundle" -Destination $bundlePath
  145. $cosignArgs = @('verify-blob', '--bundle', $bundlePath)
  146. if ($bundleFlag) {
  147. $cosignArgs += $bundleFlag
  148. }
  149. $cosignArgs += @(
  150. '--certificate-identity', "https://github.com/basecamp/hey-cli/.github/workflows/release.yml@refs/tags/v$Version",
  151. '--certificate-oidc-issuer', 'https://token.actions.githubusercontent.com',
  152. $checksumsPath
  153. )
  154. # Native exits don't trigger ErrorActionPreference=Stop on Windows PowerShell 5.1,
  155. # so check $LASTEXITCODE explicitly -- otherwise a verify failure would false-green.
  156. & cosign @cosignArgs
  157. if ($LASTEXITCODE -ne 0) {
  158. Fail 'Cosign signature verification failed'
  159. }
  160. Info 'Signature verified'
  161. }
  162. # Get-FirstRunFailureMessage diagnoses why running the freshly installed
  163. # hey.exe failed. It best-effort probes the binary's Authenticode status and
  164. # the Smart App Control state (Smart App Control blocks unsigned executables
  165. # at process creation). Every branch leads with the original failure:
  166. # diagnosis augments, never masks, the underlying error. PowerShell
  167. # 5.1-compatible.
  168. function Get-FirstRunFailureMessage([string]$Binary, [string]$Reason) {
  169. $sigStatus = $null
  170. try {
  171. $sigStatus = (Get-AuthenticodeSignature -FilePath $Binary -ErrorAction Stop).Status
  172. } catch { }
  173. # Smart App Control state: 0 = off, 1 = on, 2 = evaluation mode. Only 1
  174. # enforces; evaluation mode observes without blocking, so it must not
  175. # claim the failure.
  176. $sacState = $null
  177. try {
  178. $policy = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy' -ErrorAction Stop
  179. $sacState = $policy.VerifiedAndReputablePolicyState
  180. } catch { }
  181. $lead = "Installed hey.exe to $Binary, but running it failed: $Reason"
  182. if ("$sigStatus" -eq 'NotSigned' -and $sacState -eq 1) {
  183. return @"
  184. $lead
  185. This build of hey.exe is not code-signed, and Smart App Control is enabled. Smart App Control blocks unsigned executables no matter where they were downloaded from, and it has no per-app exceptions. Two options:
  186. 1. (Preferred) Install the Linux build inside WSL2 - Smart App Control does not apply there and your Windows security setup is untouched:
  187. wsl --install
  188. then, inside the WSL terminal:
  189. curl -fsSL https://hey.com/install-cli | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 223 on GitHub
  190. 2. Turn Smart App Control off (Windows Security > App & browser control > Smart App Control settings) and leave it off while using this unsigned build. Because there are no per-app exceptions, turning it back on re-blocks hey.exe on its next run - only re-enable after upgrading to a signed release. Windows 11 with the March/April 2026 updates can re-enable Smart App Control from Windows Security without a reset; on older builds re-enabling requires resetting Windows, so prefer the WSL2 option there.
  191. "@
  192. }
  193. if ("$sigStatus" -eq 'NotSigned') {
  194. return @"
  195. $lead
  196. This build of hey.exe is not code-signed, and Windows Security or SmartScreen may have blocked or quarantined it. Check Windows Security > Protection history for a block or quarantine event, restore or allow hey.exe, then re-run the installer.
  197. "@
  198. }
  199. return @"
  200. $lead
  201. If Windows Security or antivirus interfered, check Windows Security > Protection history, restore or allow hey.exe, then re-run the installer.
  202. "@
  203. }
  204. function Get-PathEntries {
  205. param([string]$PathValue)
  206. if (-not $PathValue) {
  207. return @()
  208. }
  209. return $PathValue -split ';' | Where-Object { $_ }
  210. }
  211. function Normalize-PathEntry([string]$PathValue) {
  212. if (-not $PathValue) {
  213. return ''
  214. }
  215. return $PathValue.Trim().TrimEnd('\')
  216. }
  217. function Get-DefaultBinDir {
  218. $currentPathEntries = Get-PathEntries $env:Path
  219. $userPathEntries = Get-PathEntries ([Environment]::GetEnvironmentVariable('Path', 'User'))
  220. $allEntries = @($currentPathEntries + $userPathEntries) | ForEach-Object { Normalize-PathEntry $_ }
  221. $homeBin = Normalize-PathEntry (Join-Path $HOME 'bin')
  222. $homeLocalBin = Normalize-PathEntry (Join-Path $HOME '.local\bin')
  223. if ($allEntries -contains $homeBin) {
  224. return $homeBin
  225. }
  226. if ($allEntries -contains $homeLocalBin) {
  227. return $homeLocalBin
  228. }
  229. return $homeBin
  230. }
  231. function Ensure-UserPath([string]$Dir) {
  232. $userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
  233. $segments = Get-PathEntries $userPath
  234. $normalizedSegments = $segments | ForEach-Object { Normalize-PathEntry $_ }
  235. $normalizedDir = Normalize-PathEntry $Dir
  236. if ($normalizedSegments -contains $normalizedDir) {
  237. return
  238. }
  239. $newPath = if ($userPath) { "$Dir;$userPath" } else { $Dir }
  240. [Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
  241. $env:Path = "$Dir;$env:Path"
  242. Info "Added $Dir to your user PATH"
  243. }
  244. function Test-InteractiveSession {
  245. if ($Host.Name -ne 'ConsoleHost' -and $Host.Name -ne 'Visual Studio Code Host') {
  246. return $false
  247. }
  248. try {
  249. return -not [Console]::IsInputRedirected -and -not [Console]::IsOutputRedirected
  250. } catch {
  251. return $false
  252. }
  253. }
  254. # Invoke-PostInstallSetup connects coding agents without prompting, but only
  255. # when the installed binary has the ownership-aware `setup agents` (it honors
  256. # HEY_SETUP_AGENT itself). Releases that predate `setup agents` also predate
  257. # the ownership gate on `skill install`, so the installer never invokes an
  258. # old binary's legacy setup or skill commands - the printed next steps are
  259. # the fallback. Best-effort: a failure here must not fail the install.
  260. function Invoke-PostInstallSetup([string]$Binary) {
  261. # The call never touches credentials, but a locked headless keychain can
  262. # block the keyring probe forever. Set the escape hatch for the duration
  263. # only, restoring the caller's value (or absence) on the way out.
  264. $savedNoKeyring = $env:HEY_NO_KEYRING
  265. $env:HEY_NO_KEYRING = '1'
  266. try {
  267. try { $help = & $Binary setup --help 2>$null } catch { $help = '' }
  268. if ($help -match '(?m)^\s+agents\s') {
  269. try {
  270. $summary = & $Binary setup agents --jq '.summary' 2>$null
  271. if ($summary) {
  272. Info "$summary"
  273. }
  274. } catch { }
  275. }
  276. } finally {
  277. if ($null -eq $savedNoKeyring) {
  278. Remove-Item Env:HEY_NO_KEYRING -ErrorAction SilentlyContinue
  279. } else {
  280. $env:HEY_NO_KEYRING = $savedNoKeyring
  281. }
  282. }
  283. }
  284. function Main {
  285. $arch = Get-PlatformArch
  286. if (-not $BinDir) {
  287. $BinDir = Get-DefaultBinDir
  288. }
  289. $resolvedVersion = if ($Version) { $Version } else { Get-LatestVersion }
  290. if ($resolvedVersion -notmatch '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$') {
  291. Fail "Invalid version '$resolvedVersion'. Expected semver format like 1.2.3 or 1.2.3-rc.1."
  292. }
  293. $archiveName = "hey_${resolvedVersion}_windows_${arch}.zip"
  294. $baseUrl = "https://github.com/$Repo/releases/download/v$resolvedVersion"
  295. Step "Downloading hey v$resolvedVersion for windows_$arch..."
  296. $tmpDir = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName())
  297. New-Item -ItemType Directory -Path $tmpDir | Out-Null
  298. try {
  299. $archivePath = Join-Path $tmpDir $archiveName
  300. $checksumsPath = Join-Path $tmpDir 'checksums.txt'
  301. $extractDir = Join-Path $tmpDir 'extract'
  302. Download-File -Url "$baseUrl/$archiveName" -Destination $archivePath
  303. Step 'Verifying checksums...'
  304. Download-File -Url "$baseUrl/checksums.txt" -Destination $checksumsPath
  305. Verify-Checksum -ChecksumsPath $checksumsPath -ArchivePath $archivePath -ArchiveName $archiveName
  306. Verify-CosignSignature -Version $resolvedVersion -BaseUrl $baseUrl -TmpDir $tmpDir
  307. Step 'Extracting...'
  308. Expand-Archive -Path $archivePath -DestinationPath $extractDir -Force
  309. $binaryPath = Join-Path $extractDir 'hey.exe'
  310. if (-not (Test-Path $binaryPath)) {
  311. Fail 'hey.exe not found in archive. If Windows Security or antivirus removed it during extraction, check Windows Security > Protection history, restore it, and re-run the installer.'
  312. }
  313. $installedBinary = Join-Path $BinDir 'hey.exe'
  314. New-Item -ItemType Directory -Force -Path $BinDir | Out-Null
  315. # Windows holds an exclusive lock on running PE files; -Force doesn't help.
  316. # Generic catch -- typed catches miss ActionPreferenceStopException wrapping.
  317. try {
  318. Copy-Item -Force $binaryPath $installedBinary -ErrorAction Stop
  319. } catch {
  320. Fail "Failed to install hey.exe. If it is in use, close any running 'hey' processes and re-run the installer. If Windows Security quarantined it, check Windows Security > Protection history and restore it. (Original error: $($_.Exception.Message))"
  321. }
  322. Ensure-UserPath -Dir $BinDir
  323. Info "Installed hey to $installedBinary"
  324. # Smart App Control kills CreateProcess for unsigned executables, so the
  325. # first run is where a block surfaces. Generic catch per the Copy-Item
  326. # precedent above. A launch that succeeds but exits nonzero does not
  327. # throw in Windows PowerShell 5.1, so check $LASTEXITCODE as well.
  328. try {
  329. $installedVersion = & $installedBinary --version
  330. } catch {
  331. Fail (Get-FirstRunFailureMessage -Binary $installedBinary -Reason $_.Exception.Message)
  332. }
  333. if ($LASTEXITCODE -ne 0) {
  334. Fail (Get-FirstRunFailureMessage -Binary $installedBinary -Reason "hey --version exited with code $LASTEXITCODE")
  335. }
  336. Info "$installedVersion installed"
  337. $isInteractive = Test-InteractiveSession
  338. Write-Host ''
  339. if ($SkipSetup -eq '1') {
  340. Step 'Skipping setup wizard (HEY_SKIP_SETUP=1)'
  341. # Still install the agent skill and connect coding agents (best-effort).
  342. Invoke-PostInstallSetup $installedBinary
  343. Write-Host ''
  344. Write-Host ' Next steps:'
  345. Write-Host ' hey auth login Authenticate with HEY'
  346. Write-Host ' hey setup Run the setup wizard'
  347. Write-Host ' hey --help See what you can do'
  348. Write-Host ''
  349. } elseif ($isInteractive) {
  350. # Setup is optional: a declined OAuth, a timeout or a busy callback port
  351. # must not turn an already-successful install into a failure. Windows
  352. # PowerShell 5.1 does not throw on native nonzero exits, but strict
  353. # configurations can, so guard the call and check $LASTEXITCODE.
  354. try { & $installedBinary setup } catch { }
  355. if ($LASTEXITCODE -ne 0) {
  356. Write-Host ''
  357. Write-Host " Setup didn't finish - hey is installed; run it again any time:"
  358. Write-Host ''
  359. Write-Host ' Next steps:'
  360. Write-Host ' hey auth login Authenticate with HEY'
  361. Write-Host ' hey setup Run the setup wizard'
  362. Write-Host ' hey --help See what you can do'
  363. Write-Host ''
  364. }
  365. } else {
  366. Info 'Skipping interactive setup because PowerShell is running non-interactively.'
  367. # Install the agent skill and connect coding agents (best-effort).
  368. Invoke-PostInstallSetup $installedBinary
  369. Write-Host ''
  370. Write-Host ' Next steps:'
  371. Write-Host ' hey auth login Authenticate with HEY'
  372. Write-Host ' hey setup Run the setup wizard'
  373. Write-Host ' hey --help See what you can do'
  374. Write-Host ''
  375. }
  376. Write-Host ' Installed executable:'
  377. Write-Host " $installedBinary"
  378. Write-Host ''
  379. Write-Host ' New terminals pick up the PATH change; in this session, use the installed executable path directly.'
  380. Write-Host ''
  381. }
  382. finally {
  383. if (Test-Path $tmpDir) {
  384. Remove-Item -Recurse -Force $tmpDir
  385. }
  386. }
  387. }
  388. Main
  389. }
scripts/install.sh · Bundled script · 537 lines · 2 findings marked
  1. #!/usr/bin/env bash
  2. # install.sh - Install the hey CLI
  3. #
  4. # Usage:
  5. # curl -fsSL https://hey.com/install-cli | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 5 on GitHub
  6. #
  7. # Options (via environment):
  8. # HEY_BIN_DIR Where to install the binary
  9. # (default: ~/bin if on PATH, else ~/.local/bin if on PATH;
  10. # otherwise ~/bin on Windows, ~/.local/bin elsewhere)
  11. # HEY_VERSION Specific version to install (default: latest)
  12. # HEY_SKIP_SETUP Set to 1 to skip the interactive setup wizard after install
  13. # (still runs `hey setup agents` to install the agent skill
  14. # and connect coding agents without prompting)
  15. # HEY_SETUP_AGENT
  16. # Which coding agent(s) `setup agents` connects:
  17. # claude | codex | all | none (default: auto-detect a single
  18. # agent; several detected connects none and lists them)
  19. #
  20. # Verification: the SHA-256 checksum is always verified against the release's
  21. # checksums.txt. When cosign is installed, checksums.txt is additionally
  22. # verified against its keyless Sigstore bundle (checksums.txt.bundle), pinned
  23. # to this repository's release workflow identity.
  24. set -euo pipefail
  25. REPO="basecamp/hey-cli"
  26. BIN_DIR="${HEY_BIN_DIR:-}"
  27. VERSION="${HEY_VERSION:-}"
  28. CURL_SCHANNEL_FALLBACK_FLAG=""
  29. CURL_LAST_ERROR=""
  30. CURL_FALLBACK_NOTED=0
  31. # Color helpers — respect NO_COLOR (https://no-color.org)
  32. if [[ -z "${NO_COLOR:-}" ]] && [[ -t 1 ]]; then
  33. bold() { printf '\033[1m%s\033[0m' "$1"; }
  34. green() { printf '\033[32m%s\033[0m' "$1"; }
  35. red() { printf '\033[31m%s\033[0m' "$1"; }
  36. dim() { printf '\033[2m%s\033[0m' "$1"; }
  37. else
  38. bold() { printf '%s' "$1"; }
  39. green() { printf '%s' "$1"; }
  40. red() { printf '%s' "$1"; }
  41. dim() { printf '%s' "$1"; }
  42. fi
  43. info() { echo " $(green "✓") $1"; }
  44. step() { echo " $(bold "→") $1"; }
  45. error() { echo " $(red "✗ ERROR:") $1" >&2; exit 1; }
  46. find_sha256_cmd() {
  47. if command -v sha256sum &>/dev/null; then
  48. echo "sha256sum"
  49. elif command -v shasum &>/dev/null; then
  50. echo "shasum -a 256"
  51. elif command -v sha256 &>/dev/null; then
  52. # FreeBSD/OpenBSD base system; -q prints the bare digest.
  53. echo "sha256 -q"
  54. else
  55. error "No SHA256 tool found (need sha256sum, shasum or sha256)"
  56. fi
  57. }
  58. path_contains_dir() {
  59. local dir="$1"
  60. [[ ":$PATH:" == *":$dir:"* ]]
  61. }
  62. default_bin_dir() {
  63. local platform="$1"
  64. if path_contains_dir "$HOME/bin"; then
  65. echo "$HOME/bin"
  66. return 0
  67. fi
  68. if path_contains_dir "$HOME/.local/bin"; then
  69. echo "$HOME/.local/bin"
  70. return 0
  71. fi
  72. if [[ "$platform" == windows_* ]]; then
  73. echo "$HOME/bin"
  74. else
  75. echo "$HOME/.local/bin"
  76. fi
  77. }
  78. # detect_platform prints "<os>_<arch>" in the exact shape the release archives
  79. # use. macOS is per-arch (darwin_amd64, darwin_arm64): no universal
  80. # "darwin_all" archive is built, and requesting one 404s.
  81. detect_platform() {
  82. local os arch
  83. os=$(uname -s | tr '[:upper:]' '[:lower:]')
  84. case "$os" in
  85. darwin) os="darwin" ;;
  86. linux) os="linux" ;;
  87. freebsd) os="freebsd" ;;
  88. openbsd) os="openbsd" ;;
  89. mingw*|msys*|cygwin*) os="windows" ;;
  90. *) error "Unsupported OS: $os" ;;
  91. esac
  92. arch=$(uname -m)
  93. case "$arch" in
  94. x86_64|amd64) arch="amd64" ;;
  95. aarch64|arm64) arch="arm64" ;;
  96. *) error "Unsupported architecture: $arch" ;;
  97. esac
  98. echo "${os}_${arch}"
  99. }
  100. detect_curl_fallback() {
  101. local version_output help_output
  102. version_output=$(curl --version 2>/dev/null || true)
  103. if [[ "$version_output" != *[Ss]channel* ]]; then
  104. return 0
  105. fi
  106. help_output=$(curl --help all 2>/dev/null || true)
  107. if [[ "$help_output" == *"--ssl-revoke-best-effort"* ]]; then
  108. CURL_SCHANNEL_FALLBACK_FLAG="--ssl-revoke-best-effort"
  109. elif [[ "$help_output" == *"--ssl-no-revoke"* ]]; then
  110. CURL_SCHANNEL_FALLBACK_FLAG="--ssl-no-revoke"
  111. fi
  112. }
  113. curl_run() {
  114. # --show-error guarantees curl writes errors to stderr even if a future caller
  115. # passes -s without -S. The Schannel revocation detection below depends on
  116. # finding CRYPT_E_NO_REVOCATION_CHECK in stderr; without --show-error a -s
  117. # caller would silently lose the fallback.
  118. local err_file status err
  119. err_file=$(mktemp "${TMPDIR:-/tmp}/hey-curl.XXXXXX")
  120. if curl --show-error "$@" 2>"$err_file"; then
  121. rm -f "$err_file"
  122. CURL_LAST_ERROR=""
  123. return 0
  124. else
  125. status=$?
  126. fi
  127. err=$(<"$err_file")
  128. rm -f "$err_file"
  129. if [[ $status -ne 0 ]] && [[ -n "$CURL_SCHANNEL_FALLBACK_FLAG" ]] && [[ "$err" == *"CRYPT_E_NO_REVOCATION_CHECK"* ]]; then
  130. if [[ $CURL_FALLBACK_NOTED -eq 0 ]]; then
  131. echo " $(bold "→") Windows certificate revocation checks are unavailable; retrying curl with ${CURL_SCHANNEL_FALLBACK_FLAG}" >&2
  132. CURL_FALLBACK_NOTED=1
  133. fi
  134. err_file=$(mktemp "${TMPDIR:-/tmp}/hey-curl.XXXXXX")
  135. if curl --show-error "$CURL_SCHANNEL_FALLBACK_FLAG" "$@" 2>"$err_file"; then
  136. rm -f "$err_file"
  137. CURL_LAST_ERROR=""
  138. return 0
  139. else
  140. status=$?
  141. fi
  142. err=$(<"$err_file")
  143. rm -f "$err_file"
  144. fi
  145. CURL_LAST_ERROR="$err"
  146. return "$status"
  147. }
  148. get_latest_version() {
  149. local url version api_json
  150. # Follow the releases/latest redirect to get the version from the final URL.
  151. # Avoids the GitHub API (no rate limiting) and grep/sed (better Windows compat).
  152. if url=$(curl_run -fsSL -o /dev/null -w '%{url_effective}' "https://github.com/${REPO}/releases/latest"); then
  153. version="${url##*/}"
  154. version="${version#v}"
  155. if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
  156. echo "$version"
  157. return 0
  158. fi
  159. fi
  160. # Fallback to the GitHub API if redirect parsing fails. Whitespace-tolerant
  161. # regex so a future GitHub format change (pretty-print, extra spaces) doesn't
  162. # silently break the fallback. Pure bash so no GNU-awk dependency.
  163. if api_json=$(curl_run -fsSL -H 'Accept: application/vnd.github+json' -H 'User-Agent: hey-cli-installer' "https://api.github.com/repos/${REPO}/releases/latest"); then
  164. if [[ $api_json =~ \"tag_name\"[[:space:]]*:[[:space:]]*\"v?([^\"]+)\" ]]; then
  165. version="${BASH_REMATCH[1]}"
  166. if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
  167. echo "$version"
  168. return 0
  169. fi
  170. fi
  171. fi
  172. error "Could not determine latest version. ${CURL_LAST_ERROR:+curl said: ${CURL_LAST_ERROR}. }If native Windows curl fails, try Scoop or PowerShell. If using Git Bash, try /usr/bin/curl instead."
  173. }
  174. # cosign_version prints the installed cosign's version (e.g. "v2.6.0"), empty
  175. # when it can't be determined. The trailing `|| true` is load-bearing: under
  176. # `set -euo pipefail` a broken cosign (nonzero `cosign version`) would
  177. # otherwise abort the whole installer from inside the caller's command
  178. # substitution — an unusable cosign must degrade to warn-and-skip, not abort.
  179. cosign_version() {
  180. cosign version 2>/dev/null | awk -F': *' '/^GitVersion/ {print $2; exit}' || true
  181. }
  182. # cosign_bundle_support decides how to verify the release's Sigstore bundle,
  183. # which is the new (protobuf, v0.3+json) format. Prints the extra verify-blob
  184. # flag to use ("" for none) and returns 0 when verification can proceed:
  185. # v3+ → new-format parsing is the default; no flag
  186. # v2.6 – v2.x → needs --new-bundle-format=true (v2.x defaults it to false)
  187. # < v2.6 → cannot verify (v2.4 chokes on the bundle's tlog key type,
  188. # v2.2 lacks the flag entirely); caller warns and skips
  189. cosign_bundle_support() {
  190. local version="$1" major minor
  191. if [[ "$version" =~ ^v?([0-9]+)\.([0-9]+)\. ]]; then
  192. major="${BASH_REMATCH[1]}"
  193. minor="${BASH_REMATCH[2]}"
  194. else
  195. return 1
  196. fi
  197. if (( major >= 3 )); then
  198. echo ""
  199. elif (( major == 2 && minor >= 6 )); then
  200. echo "--new-bundle-format=true"
  201. else
  202. return 1
  203. fi
  204. }
  205. verify_checksums() {
  206. local version="$1"
  207. local tmp_dir="$2"
  208. local archive_name="$3"
  209. local base_url="https://github.com/${REPO}/releases/download/v${version}"
  210. step "Verifying checksums..."
  211. if ! curl_run -fsSL "${base_url}/checksums.txt" -o "${tmp_dir}/checksums.txt"; then
  212. error "Failed to download checksums.txt${CURL_LAST_ERROR:+ (${CURL_LAST_ERROR})}"
  213. fi
  214. # Verify SHA256 checksum of the downloaded archive
  215. local expected actual
  216. expected=$(awk -v f="$archive_name" '$2 == f || $2 == ("*" f) {print $1; exit}' "${tmp_dir}/checksums.txt")
  217. actual=$(cd "$tmp_dir" && $(find_sha256_cmd) "$archive_name" | awk '{print $1}')
  218. [[ -n "$expected" && "$expected" == "$actual" ]] \
  219. || error "Checksum verification failed for $archive_name"
  220. info "Checksum verified"
  221. # If cosign is available and understands the bundle format, verify the signature
  222. if command -v cosign &>/dev/null; then
  223. local cosign_ver bundle_flag
  224. cosign_ver=$(cosign_version)
  225. if bundle_flag=$(cosign_bundle_support "$cosign_ver"); then
  226. step "Verifying cosign signature..."
  227. if ! curl_run -fsSL "${base_url}/checksums.txt.bundle" -o "${tmp_dir}/checksums.txt.bundle"; then
  228. error "Failed to download checksums.txt.bundle${CURL_LAST_ERROR:+ (${CURL_LAST_ERROR})}"
  229. fi
  230. local -a cosign_args=(verify-blob --bundle "${tmp_dir}/checksums.txt.bundle")
  231. if [[ -n "$bundle_flag" ]]; then
  232. cosign_args+=("$bundle_flag")
  233. fi
  234. cosign_args+=( \
  235. --certificate-identity "https://github.com/basecamp/hey-cli/.github/workflows/release.yml@refs/tags/v${version}" \
  236. --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
  237. "${tmp_dir}/checksums.txt")
  238. cosign "${cosign_args[@]}" \
  239. || error "Cosign signature verification failed"
  240. info "Signature verified"
  241. else
  242. step "Skipping signature verification: cosign ${cosign_ver:-unknown} can't verify this release's bundle format (need cosign >= 2.6)"
  243. fi
  244. fi
  245. }
  246. download_binary() {
  247. local version="$1"
  248. local platform="$2"
  249. local tmp_dir="$3"
  250. local url archive_name ext
  251. # Determine archive extension
  252. if [[ "$platform" == windows_* ]]; then
  253. ext="zip"
  254. else
  255. ext="tar.gz"
  256. fi
  257. archive_name="hey_${version}_${platform}.${ext}"
  258. url="https://github.com/${REPO}/releases/download/v${version}/${archive_name}"
  259. step "Downloading hey v${version} for ${platform}..."
  260. if ! curl_run -fsSL "$url" -o "${tmp_dir}/${archive_name}"; then
  261. error "Failed to download from $url${CURL_LAST_ERROR:+ (${CURL_LAST_ERROR})}"
  262. fi
  263. # Verify integrity before extraction
  264. verify_checksums "$version" "$tmp_dir" "$archive_name"
  265. # Extract binary
  266. step "Extracting..."
  267. if [[ "$ext" == "zip" ]]; then
  268. unzip -q "${tmp_dir}/${archive_name}" -d "$tmp_dir"
  269. else
  270. tar -xzf "${tmp_dir}/${archive_name}" -C "$tmp_dir"
  271. fi
  272. # Find and install binary
  273. local binary_name="hey"
  274. if [[ "$platform" == windows_* ]]; then
  275. binary_name="hey.exe"
  276. fi
  277. if [[ ! -f "${tmp_dir}/${binary_name}" ]]; then
  278. error "Binary not found in archive"
  279. fi
  280. mkdir -p "$BIN_DIR"
  281. mv "${tmp_dir}/${binary_name}" "$BIN_DIR/"
  282. chmod +x "$BIN_DIR/$binary_name"
  283. info "Installed hey to $BIN_DIR/$binary_name"
  284. }
  285. setup_path() {
  286. # Check if BIN_DIR is in PATH
  287. if [[ ":$PATH:" == *":$BIN_DIR:"* ]]; then
  288. return 0
  289. fi
  290. step "Adding $BIN_DIR to PATH"
  291. local shell_rc=""
  292. local path_line="export PATH=\"$BIN_DIR:\$PATH\""
  293. case "${SHELL:-}" in
  294. */zsh) shell_rc="$HOME/.zshrc" ;;
  295. # macOS terminals start bash as a login shell, which reads ~/.bash_profile
  296. # and not ~/.bashrc. Linux login shells (consoles, SSH) reach ~/.bashrc
  297. # through the distros' stock profile files.
  298. */bash) if [[ "$(uname -s)" == "Darwin" ]]; then
  299. shell_rc="$HOME/.bash_profile"
  300. else
  301. shell_rc="$HOME/.bashrc"
  302. fi ;;
  303. # fish sources neither ~/.profile nor Bourne syntax; fish_add_path
  304. # (fish >= 3.2) persists the entry and is idempotent across runs.
  305. */fish) shell_rc="${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish"
  306. path_line="fish_add_path \"$BIN_DIR\"" ;;
  307. *) shell_rc="$HOME/.profile" ;;
  308. esac
  309. if [[ -f "$shell_rc" ]] && grep -qF "$BIN_DIR" "$shell_rc" 2>/dev/null; then
  310. info "PATH already configured in $shell_rc"
  311. else
  312. mkdir -p "$(dirname "$shell_rc")"
  313. {
  314. echo ""
  315. echo "# Added by hey installer"
  316. echo "$path_line"
  317. } >> "$shell_rc"
  318. info "Added to $shell_rc"
  319. info "Run: source $shell_rc"
  320. fi
  321. }
  322. verify_install() {
  323. local platform="$1"
  324. local binary_name="hey"
  325. if [[ "$platform" == windows_* ]]; then
  326. binary_name="hey.exe"
  327. fi
  328. local installed_version err_file
  329. err_file=$(mktemp)
  330. if installed_version=$("$BIN_DIR/$binary_name" --version 2>"$err_file"); then
  331. rm -f "$err_file"
  332. info "$(green "${installed_version} installed")"
  333. return 0
  334. fi
  335. local run_error
  336. run_error=$(cat "$err_file")
  337. rm -f "$err_file"
  338. local detail="Installation failed - hey not working"
  339. if [[ -n "$run_error" ]]; then
  340. detail="$detail: $run_error"
  341. fi
  342. if [[ "$platform" == windows_* ]]; then
  343. detail="$detail
  344. Windows may have blocked the executable: Smart App Control only runs code-signed binaries.
  345. Either install inside WSL2 (curl -fsSL https://hey.com/install-cli | bash) or see
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 405 on GitHub
  346. https://github.com/basecamp/hey-cli#windows-smart-app-control-and-smartscreen"
  347. fi
  348. error "$detail"
  349. }
  350. show_banner() {
  351. echo ""
  352. echo " $(bold "HEY CLI")"
  353. echo ""
  354. }
  355. main() {
  356. show_banner
  357. # Check for curl
  358. if ! command -v curl &>/dev/null; then
  359. error "curl is required but not installed"
  360. fi
  361. local platform version tmp_dir
  362. platform=$(detect_platform)
  363. detect_curl_fallback
  364. if [[ -z "$BIN_DIR" ]]; then
  365. BIN_DIR=$(default_bin_dir "$platform")
  366. fi
  367. if [[ -n "$VERSION" ]]; then
  368. version="$VERSION"
  369. if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
  370. error "Invalid version '${version}'. Expected semver format (e.g. 1.2.3 or 1.2.3-rc.1)."
  371. fi
  372. else
  373. version=$(get_latest_version)
  374. fi
  375. tmp_dir=$(mktemp -d)
  376. # Expand now on purpose: tmp_dir is local to main and gone by the time the
  377. # EXIT trap fires.
  378. # shellcheck disable=SC2064
  379. trap "rm -rf '${tmp_dir}'" EXIT
  380. local binary_name="hey"
  381. if [[ "$platform" == windows_* ]]; then
  382. binary_name="hey.exe"
  383. fi
  384. download_binary "$version" "$platform" "$tmp_dir"
  385. setup_path
  386. verify_install "$platform"
  387. echo ""
  388. # Hand off to the setup wizard only when stdin and stdout are a terminal and
  389. # it was not explicitly skipped. Non-interactive environments (CI, piped
  390. # input, coding agents like Claude Code or Codex) get the agent skill
  391. # installed and a best-effort agent connection via `setup agents`, plus
  392. # next-step instructions — the wizard prompts, and a prompt without a
  393. # terminal would hang.
  394. if [[ "${HEY_SKIP_SETUP:-}" == "1" ]]; then
  395. step "Skipping setup wizard (HEY_SKIP_SETUP=1)"
  396. post_install_setup "$binary_name"
  397. print_next_steps
  398. elif [[ -t 0 ]] && [[ -t 1 ]]; then
  399. # Setup is optional: a declined OAuth, a timeout or a busy callback port
  400. # must not turn an already-successful install into a failure under set -e.
  401. if ! "$BIN_DIR/$binary_name" setup; then
  402. echo ""
  403. echo " Setup didn't finish — hey is installed; run it again any time:"
  404. print_next_steps
  405. fi
  406. else
  407. info "Skipping interactive setup (no terminal detected)."
  408. post_install_setup "$binary_name"
  409. print_next_steps
  410. fi
  411. }
  412. print_next_steps() {
  413. echo ""
  414. echo " Next steps:"
  415. echo " $(bold "hey auth login") Authenticate with HEY"
  416. echo " $(bold "hey setup") Run the setup wizard"
  417. echo " $(bold "hey --help") See what you can do"
  418. echo ""
  419. }
  420. # binary_supports_setup_agents reports whether the installed binary exposes the
  421. # `setup agents` subcommand. The hosted install.sh from main can outrun the
  422. # latest release, so we probe rather than assume.
  423. binary_supports_setup_agents() {
  424. "$1" setup --help 2>/dev/null | grep -qE '^[[:space:]]+agents[[:space:]]'
  425. }
  426. # post_install_setup connects coding agents without prompting, but only when
  427. # the installed binary has the ownership-aware `setup agents` (it honors
  428. # HEY_SETUP_AGENT itself: claude|codex|all|none, unset = auto-detect one).
  429. # The jq selector keeps the machine-readable command's envelope out of the
  430. # human-facing installer while preserving its concise outcome.
  431. #
  432. # Releases that predate `setup agents` also predate the ownership gate on
  433. # `skill install` — their legacy implementation overwrites whatever occupies
  434. # the skill paths — so the installer never invokes an old binary's setup or
  435. # skill commands. The printed next steps are the fallback: setup belongs to
  436. # the user, on a binary that refuses to destroy their files.
  437. #
  438. # The real invocation carries HEY_NO_KEYRING=1, per-command rather than
  439. # exported: it never touches credentials, and a locked headless keychain
  440. # (CI, ssh) could otherwise block the keyring probe forever. The
  441. # `setup --help` capability probe stays bare — help short-circuits first.
  442. post_install_setup() {
  443. local binary_name="$1"
  444. local bin="$BIN_DIR/$binary_name"
  445. local summary
  446. if binary_supports_setup_agents "$bin"; then
  447. if summary=$(HEY_NO_KEYRING=1 "$bin" setup agents --jq '.summary' 2>/dev/null); then
  448. if [[ -n "$summary" ]]; then
  449. info "$summary"
  450. fi
  451. fi
  452. fi
  453. }
  454. # Guard so sourcing the script (e.g. from tests) doesn't run the installer.
  455. # The if-form is required: `[[ … ]] && main` returns 1 when sourced, which
  456. # trips `set -e` in the sourcing shell. The `:-$0` fallback is also
  457. # required: bash executing from stdin (curl | bash) or -c leaves BASH_SOURCE
  458. # unset, and the bare expansion aborts under `set -u`.
  459. if [[ "${BASH_SOURCE[0]:-$0}" == "$0" ]]; then
  460. main "$@"
  461. fi
scripts/stage-installer-ps1.sh · Bundled script · 58 lines · 1 finding marked
  1. #!/usr/bin/env sh
  2. # Usage: scripts/stage-installer-ps1.sh SOURCE DEST
  3. #
  4. # Stage a copy of the PowerShell installer for Authenticode signing, in the
  5. # only shape where jsign's digest and PowerShell's agree.
  6. #
  7. # jsign computes the script digest as UTF-16LE of the file content with the
  8. # signature block stripped, and applies NO line-ending normalization
  9. # (SignableScript.computeDigest). PowerShell's script SIP normalizes to CRLF
  10. # before hashing. Sign an LF file and the two digests differ, so
  11. # Get-AuthenticodeSignature reports HashMismatch and the installer is refused
  12. # under AllSigned/RemoteSigned. That is what basecamp-cli
  13. # shipped in v0.8.0-rc.2, and hey-cli inherits the same pipeline.
  14. #
  15. # Two invariants make the digests agree:
  16. #
  17. # CRLF removes the normalization disagreement above.
  18. #
  19. # pure ASCII removes an encoding disagreement that CRLF alone would not
  20. # fix. The file has no BOM; jsign assumes UTF-8, but Windows
  21. # PowerShell 5.1 assumes ANSI (Windows-1252) for BOM-less files.
  22. # Any byte above 0x7F therefore decodes to different characters
  23. # on each side and the digests diverge again. Within ASCII the
  24. # two encodings are identical byte-for-byte, so the question
  25. # never arises. Adding a BOM would be the other way out, but it
  26. # trades a known-good invariant for jsign's
  27. # isByteOrderMarkSigned() matching Microsoft's undocumented
  28. # treatment of the BOM in the hash — untestable without a
  29. # signing round-trip.
  30. #
  31. # The source file is left alone: raw-main install.ps1 stays LF and unsigned,
  32. # which is the `irm | iex` path and needs neither.
  33. set -eu
  34. SRC="${1:?usage: stage-installer-ps1.sh SOURCE DEST}"
  35. DEST="${2:?usage: stage-installer-ps1.sh SOURCE DEST}"
  36. [ -f "$SRC" ] || { echo "stage-installer-ps1: source not found: $SRC" >&2; exit 1; }
  37. # Reject non-ASCII before signing rather than after. Under LC_ALL=C every byte
  38. # above 0x7F is non-printable, so this matches exactly the bytes that would
  39. # make jsign and PowerShell 5.1 disagree.
  40. if LC_ALL=C grep -n '[^[:print:][:space:]]' "$SRC" >/dev/null 2>&1; then
  41. echo "stage-installer-ps1: $SRC contains non-ASCII bytes, which would produce" >&2
  42. echo " a signature PowerShell 5.1 rejects as HashMismatch (it decodes BOM-less" >&2
  43. echo " files as Windows-1252 while jsign assumes UTF-8). Offending lines:" >&2
  44. LC_ALL=C grep -n '[^[:print:][:space:]]' "$SRC" >&2
  45. exit 1
  46. fi
  47. mkdir -p "$(dirname "$DEST")"
  48. # LF -> CRLF, idempotent: strip any existing CR first so a CRLF source does
  49. # not become CR CR LF.
  50. awk '{ sub(/\r$/, ""); printf "%s\r\n", $0 }' "$SRC" > "$DEST"
  51. echo "stage-installer-ps1: staged $DEST (pure ASCII, CRLF)"

Version history

  • v1.13.111/11/2026

  • v1.12.011/9/2026

  • v1.11.011/7/2026

  • v1.10.110/25/2026

  • v1.10.010/23/2026

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.