From 5b4e206969a4264bcc81398b87812d5999612b31 Mon Sep 17 00:00:00 2001 From: Jeremy Andre Date: Wed, 7 Oct 2026 17:21:12 +0200 Subject: [PATCH] feat: store listing media under media/// An app's store page (agentproto.sh/apps/) shows its icon and screenshots; their files live next to its entry, in media///. check-pr.mjs applies the entry's owners to its media, restricts paths and formats, caps files at 1 MB. The validate workflow also verifies the entry of any app whose media changed, and passes --local-media so media added by the PR are checked before they exist on main. README: Store page section. --- .github/workflows/validate.yml | 18 +++++++++++-- README.md | 47 ++++++++++++++++++++++++++++++-- scripts/check-pr.mjs | 49 +++++++++++++++++++++++++++++++--- 3 files changed, 106 insertions(+), 8 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 95599c2..2eda78c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -46,9 +46,23 @@ jobs: env: BASE_REF: origin/${{ github.base_ref }} run: | - mapfile -t changed < <(git diff --name-only --diff-filter=AM "$BASE_REF...HEAD" -- entries/ | grep '\.json$' || true) + # Entries added/changed, plus the entry of any app whose listing + # media (media///...) changed. + mapfile -t changed < <( + { + git diff --name-only --diff-filter=AM "$BASE_REF...HEAD" -- entries/ | grep '\.json$' || true + git diff --name-only "$BASE_REF...HEAD" -- media/ \ + | sed -nE 's#^media/(@[^/]+/[^/]+)/.*#entries/\1.json#p' || true + } | sort -u | while read -r f; do [ -f "$f" ] && echo "$f"; done + ) if [ "${#changed[@]}" -eq 0 ]; then echo "no entry added or changed"; exit 0; fi - agentproto catalog verify "${changed[@]}" + # Listing media this PR adds are not on main yet: read them from the + # checkout (CLI with store listing support only). + media=() + if agentproto catalog verify --help 2>&1 | grep -q -- "--local-media"; then + media=(--local-media "https://raw.githubusercontent.com/agentproto/apps/main/=$PWD") + fi + agentproto catalog verify "${changed[@]}" "${media[@]}" - name: Build the catalog run: | diff --git a/README.md b/README.md index 69ca669..7200bba 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ at a compiled `.agentapp` bundle hosted somewhere public. The app's source code lives wherever its publisher keeps it. - `entries/.json`: one entry per app (e.g. `entries/@acme/notes.json`). +- `media///`: icon and screenshots of an app's store page + (e.g. `media/@acme/notes/1.2.0/editor.png`). - `catalog/v1/apps.json`: generated from `entries/` on every merge to `main`. Never edit it by hand. - Releases of this repo host the bundles of first-party apps (tag @@ -58,6 +60,42 @@ An entry is an `app-catalog/v1` entry (`AppCatalogEntry` in not published in `catalog/v1/apps.json`. - `@agentproto/*` app ids are reserved to the maintainers. +## Store page (listing) + +Each app has a page at `https://agentproto.sh/apps/`. Optional entry +fields fill it in: `tagline`, `longDescription` (markdown, raw HTML is not +rendered), `screenshots` (`{url, alt, width?, height?}`), `icon`, +`categories`, `publisher`, `homepage`, `repository`. + +Declare them in your app's APP.md `store:` block and +`agentproto app pack --release --entry` writes them into the entry: + +```yaml +store: + tagline: Notes with your agents. # 1 to 120 characters + categories: [productivity, notes] # at most 5, [a-z0-9-] + publisher: Acme + homepage: https://acme.dev/notes + repository: https://github.com/acme/notes + icon: store/icon.svg # png/jpeg/webp/svg, 256 KB max + listing: store/LISTING.md # long description, markdown + screenshots: # at most 8, png/jpeg/webp, 1 MB max + - path: store/screenshots/editor.png + alt: The note editor next to an agent session # required +``` + +Local media are copied to `media///` next to the entry +and referenced from this repo +(`https://raw.githubusercontent.com/agentproto/apps/main/media///`): +add that folder to your PR, next to `entries/.json`. To host +them yourself, pack with `--media-base-url https://your.host/path` and +upload the folder there instead. All URLs must be https. + +CI checks the media the same way as the bundle: `check-pr.mjs` (paths, +owners, 1 MB cap) and `agentproto catalog verify` (format, size, alt text, +limits), reading the PR's own media from the checkout. Media of a version +stay in place once merged; a new version gets its own folder. + ## Publish your app 1. Build a release bundle and its entry: @@ -75,11 +113,16 @@ An entry is an `app-catalog/v1` entry (`AppCatalogEntry` in 3. Check it like CI will: ```bash - agentproto catalog verify notes-1.2.0.entry.json + agentproto catalog verify notes-1.2.0.entry.json \ + --local-media https://raw.githubusercontent.com/agentproto/apps/main/=. ``` + (`--local-media` reads listing media from the folder `pack` wrote, before + they are on `main`.) + 4. Copy the entry to `entries/.json`, add `"owners": [""]`, - and open a pull request. + add the `media/` folder if your app has a store listing, and open a pull + request. CI then checks the policy (paths, owners, reserved ids), downloads your bundle, and verifies its size, digest and manifest (`agentproto catalog verify`). A diff --git a/scripts/check-pr.mjs b/scripts/check-pr.mjs index 2dd3633..7410d18 100644 --- a/scripts/check-pr.mjs +++ b/scripts/check-pr.mjs @@ -9,7 +9,8 @@ // Changed files are `git diff --name-status ...HEAD`. // // Rules: -// 1. Non-maintainers (MAINTAINERS, base branch) may only touch entries/**. +// 1. Non-maintainers (MAINTAINERS, base branch) may only touch entries/** +// and media/**. // catalog/v1/apps.json is generated on main: only a maintainer may // touch it in a PR (bootstrap, repair). // 2. An entry lives at entries/.json (e.g. entries/@acme/notes.json) @@ -19,9 +20,14 @@ // published catalog) protects an app id: adding an entry requires the // author in its `owners`; changing or deleting one requires the author // in the BASE version's `owners`. Maintainers may do both. +// 5. Store listing media live in media/// +// (png/jpg/jpeg/webp/svg, 1 MB max): changing them needs the same +// ownership as entries/.json (its base owners, or the owners of +// the entry this PR adds). Format/size/alt are re-checked by +// `agentproto catalog verify --local-media`. import { execFileSync } from "node:child_process" -import { readFileSync, existsSync } from "node:fs" +import { readFileSync, existsSync, statSync } from "node:fs" import { join } from "node:path" import { parseArgs } from "node:util" @@ -40,7 +46,8 @@ if (!author || !base) { process.exit(2) } -const git = (...args) => execFileSync("git", ["-C", root, ...args], { encoding: "utf8" }) +const git = (...args) => + execFileSync("git", ["-C", root, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }) const showBase = (path) => { try { return git("show", `${base}:${path}`) @@ -77,13 +84,47 @@ const changes = git("diff", "--name-status", "--no-renames", `${base}...HEAD`) const owners = (entry) => Array.isArray(entry?.owners) ? entry.owners.map((o) => String(o).toLowerCase()) : [] +const MEDIA_RE = /^media\/(@[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9._-]*)\/[0-9A-Za-z.+-]+\/[A-Za-z0-9._-]+\.(png|jpe?g|webp|svg)$/ +const MEDIA_MAX_BYTES = 1_000_000 + +/** Owners allowed to touch an app's media: base entry owners, else the + * owners of the entry this PR adds. */ +function mediaOwners(appId) { + const entryPath = `entries/${appId}.json` + const base = showBase(entryPath) + if (base !== undefined) return owners(parseJson(base, `${entryPath} (base)`)) + const file = join(root, entryPath) + return existsSync(file) ? owners(parseJson(readFileSync(file, "utf8"), entryPath)) : [] +} + for (const { status, path } of changes) { + if (path.startsWith("media/")) { + const mm = MEDIA_RE.exec(path) + if (!mm) { + errors.push(`${path}: media must be media/@///.(png|jpg|jpeg|webp|svg)`) + continue + } + const appId = mm[1] + if (appId.startsWith("@agentproto/") && !isMaintainer) { + errors.push(`${path}: @agentproto/* app ids are reserved to maintainers`) + } + if (!isMaintainer && !mediaOwners(appId).includes(author)) { + errors.push(`${path}: ${author} is not in the owners of ${appId}`) + } + if (status !== "D") { + const file = join(root, path) + if (existsSync(file) && statSync(file).size > MEDIA_MAX_BYTES) { + errors.push(`${path}: ${statSync(file).size} bytes, over the ${MEDIA_MAX_BYTES} byte cap`) + } + } + continue + } if (path === "catalog/v1/apps.json") { if (!isMaintainer) errors.push(`${path}: generated on main by the catalog workflow, do not edit it in a PR`) continue } if (!path.startsWith("entries/")) { - if (!isMaintainer) errors.push(`${path}: only maintainers may change files outside entries/`) + if (!isMaintainer) errors.push(`${path}: only maintainers may change files outside entries/ and media/`) continue } if (path === "entries/.gitkeep") continue