sigildocs

(sigil cli manager remote)

(sigil cli manager remote) - Remote release/API helpers (post-bootstrap)

Holds every sigil cli action that touches the network: upgrade (fetch the latest release metadata + binary), use (fetch a specific version's metadata + binary), install (current binary install + zig toolchain fetch). Factored out of (sigil cli manager) so the bootstrap CLI does not have to import (sigil json) or (sigil http). Loaded lazily from cli-handler in the parent module.

============================================================ UPGRADE FLOW (METADATA-FILE DESIGN) ============================================================

The binary hardcodes ONE URL: *release-metadata-url* below. Everything else (per-platform binary URLs, sha256 checksums, release notes URL) comes from a metadata JSON file fetched at upgrade time. Shape:

{ "latest": "0.14.0", "platforms": { "linux-amd64": "https://.../v0.14.0/sigil-linux-amd64", "linux-arm64": "...", "macos-arm64": "...", "macos-amd64": "...", "windows-amd64": "..." }, "sha256": { "linux-amd64": "abc123...", ... }, "release-notes-url": "https://.../tag/v0.14.0" }

Why this shape:

  • Decouples binary-upgrade flow from any specific release-repo URL. Future repo renames are invisible to upgrade — only the metadata file gets updated, and *release-metadata-url* stays constant.
  • Per-platform binary URLs centralized in one place.
  • sha256 verification is mandatory (signature is the metadata-file domain's HTTPS cert + the JSON-encoded sha256s, end-to-end).
  • Easily extensible: add channel: later to support stable / beta / nightly without changing the fetch protocol.

Mirrors the rustup / nvm / volta / bun-upgrade / deno-upgrade pattern.

Per-version metadata files live at <base-url>/v<version>.json. The latest.json file is updated to point at whichever version is current "latest." Both shapes are identical.

Exports

The single hardcoded URL that all remote operations route through.

This is the metadata-file URL, NOT the source-repo URL and NOT a per-binary URL. Compromising or moving this URL breaks the upgrade flow; everything downstream is rename-immune.

The metadata files live in codeberg:sigil/releases and are served via Codeberg's raw-content endpoint.

Base URL for per-version metadata files. Composed as: <base>/v<version>.json e.g. https://codeberg.org/sigil/releases/raw/branch/main/v0.14.0.json. Used by sigil cli use <ver> to fetch metadata for an arbitrary version (not just the latest).

fetch-jsonprocedure

Fetch JSON from a URL. Returns: (ok . <parsed-json>) - successful fetch + parse (error . network) - connection failed or non-2xx (error . parse) - JSON parsing failed

download-fileprocedure

Stream a file to disk. Returns #t on success, #f on failure.

Fetch the latest-release metadata file.

Fetch metadata for a specific version (e.g. "0.14.0").

Compute the sha256 of a file via the system sha256sum (Linux/BSD) or shasum -a 256 (macOS). Returns the lowercase hex digest, or #f if neither tool is available.

verify-sha256procedure

Verify a file's sha256 against an expected hex digest. Returns #t on match, #f otherwise.

Atomically replace a binary at dest-path with src-path.

On Linux, you can't write to a binary that's currently executing ("text file busy"). The standard workaround is to rename the existing file out of the way first, then move the new one into place. rename(2) works even on a running executable because the kernel tracks the inode, not the dirent.

  1. Rename dest-pathdest-path.old (if it exists).
  2. Move src-pathdest-path.
  3. Make the new binary executable.
  4. Best-effort: delete dest-path.old (ignore if held open).

Returns #t on success, #f on failure.

Resolve the pinned zig download URL from ziglang.org/download/index.json.

install-zig!procedure

Download and install zig to ~/.sigil/toolchain/zig/.

sigil cli install - Install the currently-running binary to ~/.sigil. (Local operation: no remote fetch; included here because it shares helpers with handle-upgrade and the zig toolchain fetch.)

sigil cli upgrade - Fetch the latest-release metadata, compare to the running binary's version, download + verify + install if newer.

handle-useprocedure

sigil cli use <version> - Switch active version. Downloads if missing by fetching the per-version metadata file at <base>/v<version>.json.

(No description)

(No description)

(No description)

(No description)