--- name: ship description: Release and deploy one of Bryan's projects end to end on git.bjphoster.com, from a master agent, with parallel subagents that never push. Picks the pipeline per project, `bin` only (source repo and release binaries, like goreflex), `full` container + native (source -> docker packaging repo -> deployment, like proxyma), or `container` only (source -> deployment, like coredns-web-ui whose dockerfile and image live in the source repo). Use when the user says "ship", "ship [project] [bin|full|container]" (e.g. "ship proxyma 0.0.2 full", "ship 0.0.2 full" from inside a project), or asks to release, tag, publish the image and deploy a project. argument-hint: [project] [bin|full|container] [host=] --- # ship One word runs the whole flow: clean source history, tag, push, image build, deployment repo, CI babysitting, deploy. The master agent (you) gathers context, launches subagents in parallel, reviews their work, and is the only one that pushes, tags remotely, creates remote repos and deploys. ## Authorization Invoking this skill is the user's approval for this flow, for the named project only: creating the Gitea repos the profile needs, pushing the branches and the release tag, enabling Actions/packages on those repos, and deploying to the target host. It does not authorize anything outside that: no other repos, no force push to existing remote branches unless the remote repo is new or the user said so, no changes to Traefik or other services on the host beyond dropping in the new stack, no deletion of pre-existing images, volumes or data (unused build cache is fair game, see Cleanup). If a required input is missing (project path, version, deploy host, public FQDN) and memory search does not settle it, ask once with AskUserQuestion before launching subagents. Never guess the deploy host. ## Inputs Positional, in any order, recognized by shape: `ship [project] [version] [profile] [host=]`. Examples: `ship proxyma 0.0.2 full`, `ship coredns-web-ui 0.1.0-alpha2 container`, `ship 0.0.2 full`. - `version`: the token matching semver without `v` prefix, prerelease allowed (`^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$`, e.g. `0.0.1`, `0.1.0-alpha2`). Default: next patch after the latest tag; first release is `0.0.1`. Prerelease versions are tagged and published under their own tag but never move `latest`. - `profile`: the token `bin`, `full` or `container`. When given it wins over detection (below); when omitted, detect. - `project`: any other bare token, a name or a path. When omitted, use the current project: the git toplevel of the working directory, if it is a source repo (under `~/projects/sources/`, or its `origin` points at `git.bjphoster.com/source/`); the name is that directory/repo name. If there is no such project (thread without a project, cwd in a scratchpad or elsewhere), ask for it. Source lives in `~/projects/sources/`; packaging repo in `~/projects/docker/`; deployment repo in `~/projects/deployments/`. - `host=`: deploy host for profiles with a deployment, e.g. `zigbee2mqtt.home.infra.bjphoster.cloud`. When omitted, take it from memory or from an existing deployment; otherwise ask. Stack path on host: `/srv/`. ## Step 0: context (master, read only) 1. mnemory: `initialize_memory` if not done, then `search_memories` (include_decayed=true) and `find_memories` for the project, its host, the Gitea orgs and the deployment conventions. Memories are leads, verify live state before acting on them. 2. Repo state: `git status`, `git log --oneline ..HEAD`, remotes (`upstream` means a fork), existing tags, whether `origin` repos exist (`gt api /repos//`). 3. Gitea: `gt` CLI (`gt api ...`) is logged in as site admin on git.bjphoster.com; pushes go over HTTPS (credential helper `store`), SSH is denied. Org visibility (`gt api /orgs/`) decides package visibility. 4. Target host (if any): `ssh -o BatchMode=yes ` for `uname -m` (image arch), Traefik location and network subnet (`docker network inspect traefik`), certresolver name, whether the certificate for the FQDN already exists in acme.json (print only domains, never keys), DNS resolution of the FQDN, free RAM/disk. 5. Docker inventory before anything: `docker images`, `docker volume ls`, `docker buildx ls` into the scratchpad, so cleanup removes what this run added. ## Profile detection | Profile | Example | Repos | Image published from | |---|---|---|---| | `bin` | goreflex | `source/` | none (CI release binaries only) | | `full` | proxyma (container + native) | `source/` + `docker/` + `deployments/` | `docker/` (source downloaded at build time, like AUR/deb/rpm) | | `container` | coredns-web-ui, netbox-mcp-server (container only) | `source/` + `deployments/` | `source/` (dockerfile + image workflow in the source repo) | Detection, used only when no profile token was given, in order: existing `docker/` or `deployments/` repos and what the deployment compose `image:` points at; the source repo itself (a `dockerfile` plus an image workflow in `.gitea/workflows` means `container`; a native app meant to run as a service on Linux, with or without upstream Dockerfile, means `full`; a desktop/CLI app with no server to deploy means `bin`). If still ambiguous, ask. Switching an existing `container` project to `full` (adding a `docker/` repo) happens only when the user asks for `full` explicitly. ## Phases Read the reference file for each subagent before writing its brief, fill every placeholder with what Step 0 found, and keep the hard constraints verbatim. Shared rules for every brief are in [references/conventions.md](references/conventions.md); paste them in. 1. Launch in parallel, one subagent per repo the profile needs, all with `run_in_background: true`, none pushing: - source: [references/source-agent.md](references/source-agent.md) (all profiles) - packaging: [references/docker-agent.md](references/docker-agent.md) (`full` only) - deployment: [references/deployment-agent.md](references/deployment-agent.md) (`full`, `container`) The packaging and deployment agents work from the source tree read only and use `TODO` for the release commit SHA, which the master fills in. 2. If the user adds requirements while agents run, forward them with SendMessage to the agent that owns that repo, stating where they go in its commit order (before the tag). 3. Review and push, strictly in this order, each step gated on the previous one: 1. Source: review the commit list (single purpose, builds at each commit, conventions), check the final tree against the backup ref, check test results. Create the remote repo if missing (private unless the user said otherwise; for forks of GitHub projects, disable Actions so upstream `.github` workflows do not run, unless the source repo owns the image workflow in `.gitea/`). Push the branch and the release tag only. 2. `bin` profile: babysit the release CI (below) and stop. 3. Packaging (`full`): set the pinned commit to the SHA the pushed tag resolves to, commit it, review, create the repo with Actions and packages enabled, configure the Actions vars and secret (see conventions), push main and the tag. `container`: the source tag push itself triggers the image build. 4. Babysit the image CI until the image with the release tag exists in the registry for every required arch (`docker buildx imagetools inspect` or the packages API). 5. Deployment: review (compose renders with `docker compose config`, image reference matches the published one, Traefik labels per convention, trusted proxies cover the host's Traefik subnet), create the repo, push `main` only. 6. Deploy: [references/deploy.md](references/deploy.md). 4. Cleanup and report. ## CI babysitting Watch runs with `gt api /repos///actions/tasks?limit=5` (status, run number, head_sha); fetch logs of failed jobs. On failure: diagnose, fix in the owning repo as a new conventional commit (`fix:`/`ci:`), push, and for tag-triggered builds move the tag only if it was never consumed (no published image yet) and say so in the report; otherwise cut the next patch version. Do not poll with sleep loops; use the harness's wait/monitor primitives with sensible intervals. ## Cleanup Clean up the work this run did: containers, networks, volumes, buildx builders, images pulled or built that were not in the Step 0 inventory, temporary clones in the scratchpad. Then `docker builder prune -f` for the build cache: Docker never removes cache in use, and if a parallel run loses its unused cache it just rebuilds and cleans up after itself. Do not remove pre-existing images, volumes or containers. Keep backup refs (`backup/pre-rewrite`) until the user confirms, and list them. ## Report (to the user, Italian, short) Per repo: URL, pushed commits (hash + subject), tag and SHA. Image: reference, digest, arches. CI: run numbers and outcome. Deploy: host, path, URL reached over HTTPS with status code, container state. Then anything left for the user (secrets generated and where they are stored on the host, DNS records missing, backup refs to delete). Save the outcome to mnemory as an episodic memory with the date.