From 2f625dd9866087674d3380b6b6b322ea94de238c Mon Sep 17 00:00:00 2001 From: Jeremy Andre Date: Tue, 6 Oct 2026 16:17:17 +0200 Subject: [PATCH] feat: catalog index with entry validation and generated catalog entries/.json is the source of the public app catalog; catalog/v1/apps.json is regenerated from it on main and relayed at https://agentproto.sh/catalog/v1/apps.json. PRs are checked for policy (paths, owners, reserved @agentproto/* ids) and bundle integrity (agentproto catalog verify). --- .github/CODEOWNERS | 3 + .github/workflows/catalog.yml | 52 ++++++++++++++ .github/workflows/validate.yml | 56 ++++++++++++++++ MAINTAINERS | 1 + README.md | 100 +++++++++++++++++++++++++++ catalog/v1/apps.json | 5 ++ entries/.gitkeep | 0 scripts/check-pr.mjs | 119 +++++++++++++++++++++++++++++++++ 8 files changed, 336 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/catalog.yml create mode 100644 .github/workflows/validate.yml create mode 100644 MAINTAINERS create mode 100644 README.md create mode 100644 catalog/v1/apps.json create mode 100644 entries/.gitkeep create mode 100644 scripts/check-pr.mjs diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..8b39d99 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# Changes outside entries/ need a maintainer review. +* @agentiknet +/entries/ @agentiknet diff --git a/.github/workflows/catalog.yml b/.github/workflows/catalog.yml new file mode 100644 index 0000000..15cd8c7 --- /dev/null +++ b/.github/workflows/catalog.yml @@ -0,0 +1,52 @@ +name: Publish catalog + +# main: regenerate catalog/v1/apps.json from entries/ and commit it when it +# changed. https://agentproto.sh/catalog/v1/apps.json relays this file +# (raw.githubusercontent.com, cached 5 min), so a merged entry is live within +# minutes, no site deploy needed. + +on: + push: + branches: [main] + paths: ["entries/**"] + workflow_dispatch: + +concurrency: + group: publish-catalog + cancel-in-progress: false + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: 22 + + - name: Install agentproto CLI + run: npm install -g "@agentproto/cli@${{ vars.AGENTPROTO_CLI_VERSION || 'latest' }}" + + - name: Build + id: build + run: | + if agentproto catalog build entries --out catalog/v1/apps.json --check; then + echo "catalog up to date"; echo "changed=false" >> "$GITHUB_OUTPUT" + else + agentproto catalog build entries --out catalog/v1/apps.json + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Commit + if: steps.build.outputs.changed == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add catalog/v1/apps.json + git commit -m "chore(catalog): regenerate catalog/v1/apps.json" + git push diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..95599c2 --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,56 @@ +name: Validate entries + +# Every PR: policy (scripts/check-pr.mjs, taken from the BASE branch so a PR +# cannot rewrite its own rules), then bundle integrity of each added or +# changed entry (`agentproto catalog verify`: download, size, sha256, unpack, +# manifest validation, appId/version match, no ui.build), then a full +# catalog build so the merged set is known to be valid. + +on: + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + validate: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v5 + with: + node-version: 22 + + - name: Policy + env: + BASE_REF: origin/${{ github.base_ref }} + AUTHOR: ${{ github.event.pull_request.user.login }} + run: | + if git cat-file -e "$BASE_REF:scripts/check-pr.mjs" 2>/dev/null; then + git show "$BASE_REF:scripts/check-pr.mjs" > "$RUNNER_TEMP/check-pr.mjs" + else + echo "::warning::no check-pr.mjs on $BASE_REF yet, using the PR copy (bootstrap PR)" + cp scripts/check-pr.mjs "$RUNNER_TEMP/check-pr.mjs" + fi + node "$RUNNER_TEMP/check-pr.mjs" --author "$AUTHOR" --base "$BASE_REF" + + - name: Install agentproto CLI + run: npm install -g "@agentproto/cli@${{ vars.AGENTPROTO_CLI_VERSION || 'latest' }}" + + - name: Verify changed entries + 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) + if [ "${#changed[@]}" -eq 0 ]; then echo "no entry added or changed"; exit 0; fi + agentproto catalog verify "${changed[@]}" + + - name: Build the catalog + run: | + agentproto catalog build entries --out "$RUNNER_TEMP/apps.json" + echo "catalog builds: $(node -p "require('$RUNNER_TEMP/apps.json').entries.length") entries" diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 0000000..4a8ec61 --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1 @@ +agentiknet diff --git a/README.md b/README.md new file mode 100644 index 0000000..69ca669 --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ +# agentproto/apps + +The public catalog of [agentproto](https://agentproto.sh) apps. + +This repo is an **index**, not a code repo: each app is one JSON entry pointing +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`). +- `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 + `@`, asset `-.agentapp`). + +Every agentproto daemon reads the catalog at +**https://agentproto.sh/catalog/v1/apps.json**, which relays +`catalog/v1/apps.json` from this repo (cached for 5 minutes). It is what the +`/store` panel, `app_catalog` and `agentproto app catalog` list. + +## Install an app + +```bash +agentproto app install https://github.com/agentproto/apps/releases/download/%40/-.agentapp --sha256 +``` + +or from the Store: open `/store` on your daemon and click Install. The daemon +refuses a bundle whose digest differs from the catalog entry. + +## Entry format + +An entry is an `app-catalog/v1` entry (`AppCatalogEntry` in +`@agentproto/runtime`) plus `owners`: + +```json +{ + "appId": "@acme/notes", + "name": "Notes", + "description": "Take notes with your agents.", + "category": "productivity", + "version": "1.2.0", + "tier": "bundle", + "publisher": "Acme", + "license": { "kind": "free" }, + "source": { + "kind": "agentapp", + "url": "https://github.com/acme/notes/releases/download/v1.2.0/notes-1.2.0.agentapp", + "sha256": "", + "version": "1.2.0", + "size": 183204 + }, + "owners": ["acme-bot", "alice"] +} +``` + +- `source.kind` must be `agentapp`: the public catalog only lists compiled + bundles, never git sources (installing from git can run a build command). +- `owners` are GitHub logins allowed to change or remove the entry. They are + not published in `catalog/v1/apps.json`. +- `@agentproto/*` app ids are reserved to the maintainers. + +## Publish your app + +1. Build a release bundle and its entry: + + ```bash + agentproto app pack ./my-app --release --entry \ + --asset-url https://github.com///releases/download/v1.2.0/notes-1.2.0.agentapp + ``` + + `--release` builds the UI, drops sources and the build step, and writes + `notes-1.2.0.agentapp` plus `notes-1.2.0.entry.json`. +2. Upload the `.agentapp` to the URL you passed (a GitHub Release of your repo + works well). The URL must be public and must never change content: publish + a new version instead. +3. Check it like CI will: + + ```bash + agentproto catalog verify notes-1.2.0.entry.json + ``` + +4. Copy the entry to `entries/.json`, add `"owners": [""]`, + 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 +maintainer reviews and merges; the catalog updates within minutes. + +To ship an update, open a PR changing `version` and `source` in your entry. To +withdraw an app, open a PR deleting it. + +## First-party apps + +Published from the agentik-studio monorepo: a tag `app/@` builds +the app, uploads `-.agentapp` to the release `@` +of this repo, and opens a PR updating `entries/.json`. + +## Maintainers + +Listed in `MAINTAINERS`. Changes outside `entries/` need a maintainer +(`.github/CODEOWNERS`). diff --git a/catalog/v1/apps.json b/catalog/v1/apps.json new file mode 100644 index 0000000..6f53491 --- /dev/null +++ b/catalog/v1/apps.json @@ -0,0 +1,5 @@ +{ + "schema": "app-catalog/v1", + "generatedAt": "1970-01-01T00:00:00.000Z", + "entries": [] +} diff --git a/entries/.gitkeep b/entries/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/check-pr.mjs b/scripts/check-pr.mjs new file mode 100644 index 0000000..2dd3633 --- /dev/null +++ b/scripts/check-pr.mjs @@ -0,0 +1,119 @@ +#!/usr/bin/env node +// Policy check of a pull request on agentproto/apps. Run by +// .github/workflows/validate.yml from the BASE branch copy of this file, so a +// PR cannot weaken the rules it is checked against. Bundle integrity (download, +// sha256, size, unpack, manifest, no ui.build) is `agentproto catalog verify`, +// run next by the same workflow. +// +// Usage: node check-pr.mjs --author --base [--root ] +// Changed files are `git diff --name-status ...HEAD`. +// +// Rules: +// 1. Non-maintainers (MAINTAINERS, base branch) may only touch entries/**. +// 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) +// and its `appId` matches that path. +// 3. `@agentproto/*` app ids are reserved to maintainers. +// 4. `owners` (GitHub logins, kept in the entry file, stripped from the +// 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. + +import { execFileSync } from "node:child_process" +import { readFileSync, existsSync } from "node:fs" +import { join } from "node:path" +import { parseArgs } from "node:util" + +const { values } = parseArgs({ + options: { + author: { type: "string" }, + base: { type: "string" }, + root: { type: "string", default: "." }, + }, +}) +const author = (values.author ?? "").toLowerCase() +const base = values.base +const root = values.root +if (!author || !base) { + console.error("usage: check-pr.mjs --author --base [--root ]") + process.exit(2) +} + +const git = (...args) => execFileSync("git", ["-C", root, ...args], { encoding: "utf8" }) +const showBase = (path) => { + try { + return git("show", `${base}:${path}`) + } catch { + return undefined + } +} +const parseJson = (text, where) => { + try { + return JSON.parse(text) + } catch (err) { + errors.push(`${where}: invalid JSON (${err.message})`) + return undefined + } +} + +const errors = [] +const maintainers = new Set( + (showBase("MAINTAINERS") ?? "") + .split("\n") + .map((l) => l.trim().toLowerCase()) + .filter((l) => l && !l.startsWith("#")), +) +const isMaintainer = maintainers.has(author) + +const changes = git("diff", "--name-status", "--no-renames", `${base}...HEAD`) + .split("\n") + .filter(Boolean) + .map((line) => { + const [status, path] = line.split("\t") + return { status, path } + }) + +const owners = (entry) => + Array.isArray(entry?.owners) ? entry.owners.map((o) => String(o).toLowerCase()) : [] + +for (const { status, path } of changes) { + 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/`) + continue + } + if (path === "entries/.gitkeep") continue + const m = /^entries\/(@[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9._-]*)\.json$/.exec(path) + if (!m) { + errors.push(`${path}: entries must be entries/@/.json (lowercase)`) + continue + } + const appId = m[1] + if (appId.startsWith("@agentproto/") && !isMaintainer) { + errors.push(`${path}: @agentproto/* app ids are reserved to maintainers`) + } + const before = status === "A" ? undefined : parseJson(showBase(path) ?? "null", `${path} (base)`) + if (status !== "A" && !isMaintainer && !owners(before).includes(author)) { + errors.push(`${path}: ${author} is not in the owners of ${appId}`) + } + if (status === "D") continue + const file = join(root, path) + if (!existsSync(file)) continue + const entry = parseJson(readFileSync(file, "utf8"), path) + if (!entry) continue + if (entry.appId !== appId) errors.push(`${path}: appId is ${JSON.stringify(entry.appId)}, expected "${appId}"`) + if (owners(entry).length === 0) errors.push(`${path}: owners must list at least one GitHub login`) + if (status === "A" && !isMaintainer && !owners(entry).includes(author)) { + errors.push(`${path}: a new entry must list its author (${author}) in owners`) + } +} + +if (errors.length > 0) { + for (const e of errors) console.error(`check-pr: ${e}`) + process.exit(1) +} +console.log(`check-pr: ok (${changes.length} changed file(s), author ${author}${isMaintainer ? ", maintainer" : ""})`)