# sosie [![ci](https://github.com/stickerdaniel/sosie/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/stickerdaniel/sosie/actions/workflows/ci.yml?query=branch%3Amain) [![release](https://img.shields.io/github/v/release/stickerdaniel/sosie?sort=semver)](https://github.com/stickerdaniel/sosie/releases/latest) [![license Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/stickerdaniel/sosie/blob/main/LICENSE) sosie draws GitHub comments, review threads and whole reviews as github.com shows them, in light and dark, without a browser. An agent can check its comment as an image before it posts it, or send you the image and post only after your OK. [sosie.page](https://sosie.page) shows each kind of render that sosie draws. ## When to use sosie Use sosie when an agent needs to see a GitHub comment, review comment, whole review or Markdown body the way github.com shows it, as an image, without a browser. - Check a draft before posting: write the comment as a spec ([example](https://github.com/stickerdaniel/sosie/blob/main/examples/comment/spec.json)), then run `sosie resolve spec.json - | sosie render - draft` and look at `draft-light.webp` and `draft-dark.webp`. - Get a person's OK before posting: render the draft the same way, send them the image, and post only after they approve. On exit status 3, also send them the losses that stderr names. - Show a posted comment or review elsewhere: run `sosie resolve - | sosie render - out --format png` and attach the PNG to Slack, an email or a social post. - Show before and after numbers: run `sosie chart metrics.json chart` ([example](https://github.com/stickerdaniel/sosie/blob/main/examples/chart/metrics.json)). sosie creates nothing on GitHub. `resolve` sends the draft Markdown to GitHub's Markdown API, so resolve no draft that GitHub must not see. `resolve` needs network access to `api.github.com` and `avatars.githubusercontent.com`, and sends `GH_TOKEN` or `GITHUB_TOKEN` to `api.github.com` only. `render` and `chart` run offline. Exit status 3 means `render` simplified content, and stderr names each loss. ## Install On macOS or Linux: ```sh curl -fsSL https://sosie.page/install | sh ``` On Windows, in PowerShell: ```powershell irm https://sosie.page/install.ps1 | iex ``` The script installs the latest release into `~/.local/bin`, or `%LOCALAPPDATA%\sosie\bin` on Windows, and refuses an archive whose SHA-256 differs from the release's `SHA256SUMS`. `sh -s -- --version 0.2.0` or `SOSIE_VERSION=0.2.0` installs another release, and `SOSIE_INSTALL_DIR` sets the directory. To install by hand, download your platform's archive and `SHA256SUMS` from the [latest release](https://github.com/stickerdaniel/sosie/releases/latest): | Platform | Archive | | --- | --- | | macOS, Apple silicon | `sosie--darwin-arm64.tar.gz` | | macOS, Intel | `sosie--darwin-x64.tar.gz` | | Linux x86-64, glibc 2.35 or newer | `sosie--linux-x64.tar.gz` | | Linux arm64, glibc 2.35 or newer | `sosie--linux-arm64.tar.gz` | | Windows x86-64 | `sosie--win32-x64.zip` | Then, on an Apple silicon Mac: ```sh archive="$(grep -o 'sosie-[^ ]*-darwin-arm64\.tar\.gz' SHA256SUMS)" grep " $archive\$" SHA256SUMS | shasum -a 256 -c && tar -xzf "$archive" && mkdir -p ~/.local/bin && mv "${archive%.tar.gz}/sosie" ~/.local/bin/ && ~/.local/bin/sosie --version ``` GitHub attests each archive's build. To build the [v0.4.0 release](https://github.com/stickerdaniel/sosie/releases/tag/v0.4.0) from source with Rust and Cargo: ```sh cargo install --git https://github.com/stickerdaniel/sosie --tag v0.4.0 --locked sosie-cli ``` ## Example In a clone of this repository: ```sh sosie render examples/comment/resolved.json comment ``` The command writes `comment-light.webp` and `comment-dark.webp`: An issue comment with typed emoji and greetings in Chinese, Arabic and Hebrew, drawn by sosie ## Commands | Command | Arguments | Options and defaults | Prints | | --- | --- | --- | --- | | `sosie render` | ` ` | `--width 800`, `--dpr 2`, `--font-scale 1`, `--format webp`, `--fast` off and PNG only | the two image paths | | `sosie explain` | `` | `--width 800`, `--dpr 2`, `--font-scale 1` | the layout report as JSON | | `sosie resolve` | ` `, or a GitHub link in place of `` | none | the path of the resolved file | | `sosie chart` | ` ` | `--width 978`, `--format webp` | the two image paths | - `resolve` sends the Markdown of a spec through GitHub's Markdown API. From a link, it reads the posted HTML of a description or a comment, and rebuilds a review comment or a whole review at the pull request's head. It creates nothing on GitHub. - `render` draws a resolved file offline: a comment, a Markdown body, a review comment or a whole review. `chart` draws before and after numbers as bars. - `render` and `chart` write `-light.webp` and `-dark.webp`, lossless WebP. `--format png` writes PNG for a receiver without WebP support, such as Slack image blocks, Outlook for Windows or a LinkedIn or Facebook `og:image`. - An input path of `-` reads stdin. With `-` as its output, `resolve` prints the JSON, so `resolve` can pipe into `render`. - `resolve` reads a token from `GH_TOKEN`, then `GITHUB_TOKEN`, and sends it to `api.github.com` only. - Exit status 0 means success, also with warnings that lose nothing. 3 means `render` wrote both images but simplified content, and stderr names each loss; `--allow-fallback` turns 3 into 0. 2 means the input is wrong. 1 means a file, encoder, network or GitHub error. - `sosie --help` lists the arguments, the options and their ranges. [`examples`](https://github.com/stickerdaniel/sosie/tree/main/examples) holds a sample of each input file. [SPEC.md](https://github.com/stickerdaniel/sosie/blob/main/SPEC.md#coverage) lists the elements sosie draws, and [CONTRIBUTING.md](https://github.com/stickerdaniel/sosie/blob/main/CONTRIBUTING.md) the checks. Report a bug with an [issue form](https://github.com/stickerdaniel/sosie/issues/new/choose) and a vulnerability as [SECURITY.md](https://github.com/stickerdaniel/sosie/blob/main/SECURITY.md) describes. ## License Apache-2.0. See [LICENSE](https://github.com/stickerdaniel/sosie/blob/main/LICENSE) and [NOTICE](https://github.com/stickerdaniel/sosie/blob/main/NOTICE). The fonts in [`assets/fonts`](https://github.com/stickerdaniel/sosie/tree/main/assets/fonts) are under the SIL Open Font License 1.1.