feat: session-first workspace activity and installable daemon

Workspaces page:
- list the newest sessions across workspaces in the activity column; the
  daemon exposes GET /api/v1/sessions/recent as a disk projection and the
  browser enriches live rows from the per-workspace session relay
- put recent activity first below 1100px and fix the mobile page-header
  flex-basis gap

Smoke:
- pin PI2_HOST=127.0.0.1 in both smoke scripts and make the startup-line
  assertion follow the configured host; the daemon default stays 0.0.0.0

Install:
- standalone binary build/install scripts, packaging templates, CI/release
  hooks, CLI-first install docs and the supporting config/doctor changes
This commit is contained in:
yuez committed 2026-10-28 10:53:48 +08:00
1 parent fc51c3be37
commit d2e20d428a
50 files changed
+5104 -188

No files matched your search

+127
View File
@@ -0,0 +1,127 @@
# System Packaging Channels for pi2d
This directory contains the packaging templates and documentation for distributing
`pi2d` across system-level package channels.
## Distribution Channels
Every channel distributes the prebuilt single-binary artifacts built from Bun, bundling
both the CLI launcher and the React web console.
| Channel | Target Audience | User Installation Command |
|---|---|---|
| **curl installer** | Generic Linux & macOS | `curl -fsSL https://raw.githubusercontent.com/zgs225/pi2d/main/scripts/install.sh \| sh` |
| **Homebrew tap** | macOS & Linux (Homebrew) | `brew install zgs225/tap/pi2d` |
| **Arch AUR (`-bin`)** | Arch Linux / Manjaro / EndeavourOS | `paru -S pi2d-bin` (or `yay -S pi2d-bin`) |
### Shared Tarball Layout Contract
All distribution channels consume the release tarballs published on GitHub Releases:
```
https://github.com/zgs225/pi2d/releases/download/v<VERSION>/pi2d-<VERSION>-<target>.tar.gz
```
Where `<target>` is one of:
- `linux-x64`
- `linux-arm64`
- `linux-x64-musl`
- `linux-arm64-musl`
- `darwin-x64`
- `darwin-arm64`
Each release tarball unpacks with the following layout at its root:
```
bin/
pi2
share/
pi2d/
web/
dist/
index.html
...
LICENSE
```
**Crucial layout rule**: `pi2` resolves its web console assets at runtime via:
```typescript
resolve(dirname(executablePath()), "..", "share", "pi2d", "web", "dist")
```
(defined in `src/core/install.ts`).
Every channel must install `bin/pi2` into `<prefix>/bin` and `share/pi2d/web/dist` into
`<prefix>/share/pi2d/web/dist` under the same prefix (e.g. `/usr/local`, `/opt/homebrew`,
or `/usr`).
## Files & Templates
- `packaging/homebrew/pi2d.rb.in`: plain template for Homebrew formula `pi2d.rb`. Contains
platform stanzas (`on_macos`, `on_linux` with `on_arm` and `on_intel`) and `install` /
`test` / `caveats` blocks. Linux stanzas target standard glibc releases.
- `packaging/aur/PKGBUILD.in`: plain template for the Arch Linux AUR package `pi2d-bin`.
Uses `options=('!strip')` because Bun binaries embed bytecode/metadata that strip damages.
Targets x86_64 and aarch64 glibc tarballs (Alpine/musl tarballs are omitted for Arch).
- `scripts/update-packaging.sh`: deterministic generator script substituting placeholders
and validating checksums.
## One-Time Bootstrap
### 1. Homebrew Tap (`zgs225/homebrew-tap`)
1. Create a public repository on GitHub named `zgs225/homebrew-tap`.
2. Create the `Formula/` directory in that repository.
3. Place the initial `Formula/pi2d.rb` generated by `scripts/update-packaging.sh`.
4. Commit and push to `main`.
5. Users can now install with:
```bash
brew install zgs225/tap/pi2d
```
### 2. Arch Linux AUR (`pi2d-bin`)
1. Register an account on [aur.archlinux.org](https://aur.archlinux.org) and add your SSH public key.
2. Initialize the AUR package repository locally:
```bash
git clone ssh://aur@aur.archlinux.org/pi2d-bin.git
```
3. Generate the initial `PKGBUILD` and `.SRCINFO` using `scripts/update-packaging.sh`.
4. Copy `PKGBUILD` and `.SRCINFO` into the cloned `pi2d-bin` directory, commit, and push:
```bash
git add PKGBUILD .SRCINFO
git commit -m "feat: initial release"
git push origin master
```
5. Set up an SSH private key as a repository secret (e.g. `AUR_SSH_KEY`) in GitHub repository
`zgs225/pi2d` so the release workflow can push updates to the AUR repository.
## Release-Time Bump Flow
During a release (via GitHub Actions workflow when a version tag `vX.Y.Z` is pushed):
1. The release job builds binary tarballs for all 6 targets and generates `SHA256SUMS`.
2. The packaging step executes:
```bash
bash scripts/update-packaging.sh --version <VERSION> --checksums dist-bin/SHA256SUMS --out build/packaging
```
3. The generated `build/packaging/pi2d.rb` is committed and pushed to `Formula/pi2d.rb` in
the `zgs225/homebrew-tap` repository.
4. The generated `build/packaging/PKGBUILD` and `build/packaging/.SRCINFO` are committed
and pushed to the `pi2d-bin` AUR repository.
## Local Regeneration
You can regenerate or preview packaging files locally at any time:
```bash
# Using a local SHA256SUMS file:
bash scripts/update-packaging.sh --version 0.1.6 --checksums dist-bin/SHA256SUMS --out build/packaging
# Using a directory containing release tarballs:
bash scripts/update-packaging.sh --version 0.1.6 --checksums dist-bin/ --out build/packaging
# Downloading checksums directly from a published GitHub release:
bash scripts/update-packaging.sh --version 0.1.6 --out build/packaging
```
The script performs validation:
- Checks that all 6 target SHA-256 sums are accounted for.
- Fails loudly on unknown targets or malformed checksums.
- Verifies that no unreplaced `@@...@@` placeholders remain.
- Generates a valid `.SRCINFO` (using `makepkg --printsrcinfo` if installed, or an identical fallback).
+41
View File
@@ -0,0 +1,41 @@
# Maintainer: zgs225 <zgs225@gmail.com>
pkgname=pi2d-bin
pkgver=@@VERSION@@
pkgrel=1
pkgdesc="Web console daemon for pi2.nvim"
arch=('x86_64' 'aarch64')
url="https://github.com/zgs225/pi2d"
license=('MIT')
provides=('pi2d')
conflicts=('pi2d')
# Prebuilt binary compiled by Bun; stripping the executable can corrupt internal
# bundle offsets, embedded resources, and runtime metadata.
options=('!strip')
# Note on musl: upstream also publishes linux-x64-musl and linux-arm64-musl targets
# for musl-based distributions such as Alpine Linux. Arch Linux is glibc-based,
# so the standard glibc tarballs (linux-x64 and linux-arm64) are used here.
source_x86_64=("https://github.com/zgs225/pi2d/releases/download/v${pkgver}/pi2d-${pkgver}-linux-x64.tar.gz")
sha256sums_x86_64=('@@SHA256_LINUX_X64@@')
source_aarch64=("https://github.com/zgs225/pi2d/releases/download/v${pkgver}/pi2d-${pkgver}-linux-arm64.tar.gz")
sha256sums_aarch64=('@@SHA256_LINUX_ARM64@@')
# No .install script needed: pi2d runs as an unprivileged user process or user
# service. Systemd user service units can be generated via `pi2 install-service --write`.
package() {
# Daemon CLI binary (0755)
install -Dm755 "${srcdir}/bin/pi2" "${pkgdir}/usr/bin/pi2"
# Static web UI assets: /usr/share/pi2d/web/dist (0644 tree)
install -dm755 "${pkgdir}/usr/share/pi2d"
cp -r --no-preserve=ownership "${srcdir}/share/pi2d/web" "${pkgdir}/usr/share/pi2d/"
find "${pkgdir}/usr/share/pi2d/web" -type d -exec chmod 0755 {} +
find "${pkgdir}/usr/share/pi2d/web" -type f -exec chmod 0644 {} +
# Upstream license
install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
+44
View File
@@ -0,0 +1,44 @@
class Pi2d < Formula
desc "Web console daemon for pi2.nvim"
homepage "https://github.com/zgs225/pi2d"
version "@@VERSION@@"
license "MIT"
on_macos do
on_arm do
url "https://github.com/zgs225/pi2d/releases/download/v@@VERSION@@/pi2d-@@VERSION@@-darwin-arm64.tar.gz"
sha256 "@@SHA256_DARWIN_ARM64@@"
end
on_intel do
url "https://github.com/zgs225/pi2d/releases/download/v@@VERSION@@/pi2d-@@VERSION@@-darwin-x64.tar.gz"
sha256 "@@SHA256_DARWIN_X64@@"
end
end
on_linux do
on_arm do
url "https://github.com/zgs225/pi2d/releases/download/v@@VERSION@@/pi2d-@@VERSION@@-linux-arm64.tar.gz"
sha256 "@@SHA256_LINUX_ARM64@@"
end
on_intel do
url "https://github.com/zgs225/pi2d/releases/download/v@@VERSION@@/pi2d-@@VERSION@@-linux-x64.tar.gz"
sha256 "@@SHA256_LINUX_X64@@"
end
end
def install
bin.install "bin/pi2"
(share/"pi2d").install "share/pi2d/web"
end
def caveats
<<~EOS
To run pi2d as a background service:
pi2 install-service --write
EOS
end
test do
assert_match version.to_s, shell_output("#{bin}/pi2 --version")
end
end