Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/<appId>/<version>/...) 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: |
Expand Down
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ at a compiled `.agentapp` bundle hosted somewhere public. The app's source code
lives wherever its publisher keeps it.

- `entries/<appId>.json`: one entry per app (e.g. `entries/@acme/notes.json`).
- `media/<appId>/<version>/`: 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
Expand Down Expand Up @@ -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/<slug>`. 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/<appId>/<version>/` next to the entry
and referenced from this repo
(`https://raw.githubusercontent.com/agentproto/apps/main/media/<appId>/<version>/<file>`):
add that folder to your PR, next to `entries/<appId>.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:
Expand All @@ -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/<appId>.json`, add `"owners": ["<your-login>"]`,
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
Expand Down
49 changes: 45 additions & 4 deletions scripts/check-pr.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// Changed files are `git diff --name-status <base>...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/<appId>.json (e.g. entries/@acme/notes.json)
Expand All @@ -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/<appId>/<version>/<file>
// (png/jpg/jpeg/webp/svg, 1 MB max): changing them needs the same
// ownership as entries/<appId>.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"

Expand All @@ -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}`)
Expand Down Expand Up @@ -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/@<scope>/<name>/<version>/<file>.(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
Expand Down
Loading