# Install Beankeeper

You are helping the user install Beankeeper Desktop on their computer so they can keep their books locally and talk to them through AI.

Follow these steps in order. Do not ask the user to open a terminal or handle passphrases, recovery kits, or tokens. Never hardcode or pin a release version; resolve the latest signed release dynamically from https://beankeeper.app/download/latest/version.txt. Download installers and release files from https://beankeeper.app/download/latest/ (or https://beankeeper.app/download/<version>/). Do not send the user to GitHub.

## 1. Check whether Beankeeper is already installed

Check for `bk` on `PATH` and in the default per-user location:
- macOS / Linux: `"$HOME/.local/bin/bk"`
- Windows: `"$env:LOCALAPPDATA\Programs\Beankeeper Desktop\bk.exe"`

If `bk` exists and supports both `bk service install --help` and `bk agents connect --help`, check `bk service status --json`:
- If `installed` is `false`, run `bk service install --no-agents`.
- If `installed` is `true` and `running` is `false`, run `bk service start`.
- Run `bk agents connect --all --json` and `bk agents doctor --json`, then jump to step 5.

## 2. Check your environment and OS support

Detect the operating system and CPU architecture (`uname -s` and `uname -m` on macOS/Linux; `$env:OS` and `$env:PROCESSOR_ARCHITECTURE` on Windows):
- Supported: macOS (`arm64` / `x86_64`), Linux (`x86_64` / `aarch64`, glibc 2.35+), and Windows x64 (`AMD64`).
- Not yet supported: Windows ARM64. If the user is on Windows ARM64, tell them plainly and stop.
- Note for Linux: `bk service install` requires a logged-in desktop user session with an unlocked D-Bus Secret Service (such as GNOME Keyring or KWallet) to store the encrypted ledger passphrase.

If you do not have local shell access on the user's computer (for example, in a web chat or a chat-only desktop app that cannot run local commands):
- Tell the user honestly that this chat cannot run commands on their computer.
- Ask them to paste `Install Beankeeper for me by following https://beankeeper.app/install.md` into a local AI app that can work with files on their computer (such as Claude Code, Codex, Cursor, Gemini CLI, VS Code, or Grok Build). Running it there installs Beankeeper and automatically connects the Claude app on the same computer too. If you mention Claude Code, say that Claude Code, Anthropic's coding tool, is a different app from the Claude app.
- If they only have the Claude app and no AI app that can work with files on their computer, this chat cannot install Beankeeper itself, but the Claude app works with Beankeeper today as an extension. Tell them to download the Beankeeper file for their computer from this site — Mac (Apple chip): https://beankeeper.app/download/latest/claude-mac-apple-silicon.mcpb ; Mac (Intel): https://beankeeper.app/download/latest/claude-mac-intel.mcpb ; Windows: https://beankeeper.app/download/latest/claude-windows.mcpb — then follow Anthropic's steps at https://support.claude.com/en/articles/10949351-getting-started-with-local-mcp-servers-on-claude-desktop, and say "Set up my books" once it's added. One-step setup is coming soon. Do not send them to GitHub. ChatGPT cannot be connected yet; it's on the roadmap.

## 3. Ensure verification tools are ready

Every Beankeeper release is verified with a SHA-256 checksum and a keyless Sigstore (`cosign`) signature bound to the `Govcraft/beankeeper-desktop` release workflow.

### macOS and Linux
Check for `curl`, `tar`, `shasum` or `sha256sum`, `jq`, and `cosign`:
1. If `jq` or `cosign` is missing, install it with the user's package manager (for example `brew install jq cosign` on macOS, or `apt` / `dnf` / `pacman` on Linux) after telling the user what you are installing.
2. If `jq` still cannot be installed, read the latest signed release version from `https://beankeeper.app/download/latest/version.txt` (a single line such as `0.1.0-rc.29`) and pass `BK_VERSION=<VERSION>` to `install.sh`.
3. If `cosign` cannot be installed, do not silently skip signature verification. Tell the user that Sigstore authenticity verification needs `cosign`, and ask whether they want you to verify with `gh attestation verify` (if `gh` is available) or SHA-256 only (`BK_REQUIRE_SIGNATURES=0`) before proceeding.

### Windows (x64, PowerShell 5.1+)
1. Check for `cosign`. If missing, offer to install it (`winget install --id Sigstore.Cosign -e`).
2. If `cosign` cannot be installed, ask the user before falling back to SHA-256-only verification (omitting `-RequireSignatures`).

## 4. Download, verify, and install

The installer script you download from this site still retrieves the signed archive itself and verifies its Sigstore signature and checksums. Until a Beankeeper Desktop change lands, that retrieval may use GitHub; do not send the user there.

### macOS and Linux
Run as the logged-in desktop user (do not use `sudo`):

```sh
(
    set -eu
    bk_bin="$HOME/.local/bin"
    bk_download="$(mktemp -d)"
    trap 'rm -rf "$bk_download"' EXIT
    mkdir -p "$bk_bin"
    curl -fsSL https://beankeeper.app/download/latest/install.sh -o "$bk_download/install.sh"
    BK_REQUIRE_SIGNATURES=1 BK_REQUIRE_AGENT_SETUP=1 BK_INSTALL="$bk_bin" BK_NO_SERVICE=1 \
        sh "$bk_download/install.sh"
    "$bk_bin/bk" service install --no-agents
    "$bk_bin/bk" agents connect --all --json
    "$bk_bin/bk" service status --json
)
```

### Windows (PowerShell 5.1+)
Run as the logged-in desktop user:

```powershell
& {
    $ErrorActionPreference = 'Stop'
    $bkDir = Join-Path $env:LOCALAPPDATA 'Programs\Beankeeper Desktop'
    $bkSetup = Join-Path ([IO.Path]::GetTempPath()) ("bk-install-" + [guid]::NewGuid() + ".ps1")
    try {
        Invoke-WebRequest -UseBasicParsing -Uri 'https://beankeeper.app/download/latest/install.ps1' -OutFile $bkSetup
        & $bkSetup -RequireSignatures -RequireAgentSetup -NoService -InstallDir $bkDir
        $bk = Join-Path $bkDir 'bk.exe'
        & $bk service install --no-agents
        if ($LASTEXITCODE -ne 0) { throw 'Beankeeper service installation failed' }
        & $bk agents connect --all --json
        if ($LASTEXITCODE -ne 0) { throw 'Beankeeper agent registration failed' }
        & $bk service status --json
        if ($LASTEXITCODE -ne 0) { throw 'Could not read Beankeeper service status' }
    } finally {
        Remove-Item -LiteralPath $bkSetup -Force -ErrorAction SilentlyContinue
    }
}
```

If verification fails, stop immediately before running any downloaded binary and report the exact failure to the user.

## 5. Verify connections and hand off to chat

1. Run `bk agents doctor --json` (using the full installed binary path if it is not yet on `PATH`).
2. Check that the background service is running and read the `books` path from `bk service status --json`.
3. Never read, display, or speak the recovery kit, passphrase, or agent tokens.
4. Reply to the user in plain, calm language:
   - Confirm which version of Beankeeper was installed and which AI apps were connected (for example the Claude app, Claude Code, Codex, Cursor, Gemini CLI, VS Code, or Grok Build). When talking to the owner, call Claude Desktop "the Claude app," and if you mention Claude Code, say that Claude Code, Anthropic's coding tool, is a different app from the Claude app.
   - Give the exact path to their encrypted books file and to the private recovery kit saved next to the books (usually in the beankeeper-desktop folder). Ask them to keep an offline copy of both the books and the kit. You may help them find, print, or copy those files; never read or speak the kit's contents, the passphrase, or any token.
   - Ask them to quit the Claude app, or their other AI app, and open it again if that app asks, so the Beankeeper tools appear, then say **"Set up my books"**. To try practice books first, say **"Create demo books"**, and suggest they keep their spreadsheet until they're comfortable. After setup, the everyday loop is **"Check my accounts for anything new."** If their AI can reach their bank with tools it already has (a bank connector, or signing in through a browser it controls), it should bring in what's new that way. A statement file the owner shares is a fallback, not the main path. Beankeeper itself does not connect to banks. Don't promise that a specific bank will work.

