# `@themonk-ai/install`

Thin npx wrapper that downloads the platform-specific Monk Router data plane
binary from GitHub Releases, verifies its Ed25519 release signature and SHA256
checksum, writes `~/.monk-router/config.json`, and launches the binary.

## macOS quarantine strip

On macOS, downloaded files inherit a `com.apple.quarantine` extended attribute
that triggers Gatekeeper warnings on first launch. The Monk Router binary is
**not notarized** (per ADR 0014), so Gatekeeper would block it. After
extracting the binary to `~/.monk-router/bin/`, the installer runs
`xattr -cr <binary>` to strip all extended attributes, allowing the binary to
launch without a Gatekeeper prompt. A message is printed for transparency.

If the `xattr` command is unavailable or fails, the installer logs a warning
but continues — the binary may still run, and the user can strip the attribute
manually with `xattr -cr ~/.monk-router/bin/monk-router`.

## Usage

See the top-level [README.md](../README.md) for installation instructions.

## Development

```bash
npm install
npm test
npm run typecheck
```

## Production build

The embedded Ed25519 public key in `src/signing-key.ts` is a development/test
key. Before publishing the package, inject the production signing public key:

```bash
export MONK_INSTALLER_PUBLIC_KEY_HEX="<64-hex-char public key>"
bash scripts/inject-signing-key.sh
npm run build
npm publish
```

`npm run build:prod` runs `inject-signing-key.sh` followed by `tsc`.

## Release signing

The [release workflow](../.github/workflows/release.yml) generates
`signature.bin` from the `INSTALLER_SIGNING_PRIVATE_KEY` GitHub secret. The
installer downloads `signature.bin` alongside the archive and verifies the
archive signature using the embedded public key before checking the SHA256
checksum.

## Signature verification

The installer verifies each downloaded archive against an Ed25519 signature
before checking the SHA256 checksum. Two keys are in play:

- **Production public key:**
  `0510245c13285fe521e63d739023819548fcdccc7d0b62abf032617c529557f1` —
  stored as a GitHub Actions secret and used in CI. Release archives built by
  the [release workflow](../.github/workflows/release.yml) are signed with the
  corresponding private key and ship a `signature.bin` alongside the archive.
  Users installing from an official release do **not** need to pass
  `--no-signature`; verification succeeds out of the box.
- **Dev/test public key:**
  `2fe6e0e76c3a25fa8c53d3e8596ea2bf12f4ed2887cd769579f58e1257ad6550` —
  embedded in `src/signing-key.ts` and used by local builds. Manually-built
  releases are signed with a throwaway dev private key whose public half does
  **not** match the production key, so signature verification will fail. Users
  installing from a manually-built release must pass `--no-signature` to skip
  verification:

  ```bash
  npx @themonk-ai/install --no-signature
  ```

The production key is injected at publish time by
`scripts/inject-signing-key.sh`, which reads the
`MONK_INSTALLER_PUBLIC_KEY_HEX` environment variable and rewrites
`EMBEDDED_PUBLIC_KEY_HEX` in `src/signing-key.ts` before the build. Local
development and tests keep the dev key embedded; only CI/CD runs the injection
step (see [Production build](#production-build)).
