diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 463ec60..67ad7df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -599,10 +599,52 @@ jobs: working-directory: template run: docker compose -f .agentage/compose.json logs --no-color --tail 80 || true + # The real `agentage extension create` on this change's template/ folder, then verify in the created folder. + template-create: + name: Template create (${{ matrix.case }}) + needs: template-changes + if: needs.template-changes.outputs.run == 'true' + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + include: + - { case: short id, id: ab, parts: '' } + - { case: long id, id: a-very-long-extension-id, parts: '' } + - { case: api part only, id: demo, parts: api } + - { case: app and api, id: demo, parts: app api } + steps: + - name: Setup Node.js + uses: actions/setup-node@v7 + with: + node-version: 22 + + # --no-install: without it create would build the folder and give it to a local daemon. + - name: agentage extension create from this change's template/ + env: + ID: ${{ matrix.id }} + PARTS: ${{ matrix.parts }} + REPO: ${{ github.event.pull_request.head.repo.full_name || github.repository }} + REF: ${{ github.head_ref || github.ref_name }} + run: | + set -euo pipefail + mkdir "$RUNNER_TEMP/made" && cd "$RUNNER_TEMP/made" + npx -y @agentage/cli@0.72.0 extension create "$ID" $PARTS --from "$REPO#$REF:template" --yes --no-install + + - name: Install, commit (build needs a clean git tree) and verify + working-directory: ${{ runner.temp }}/made/extension-${{ matrix.id }} + run: | + set -euo pipefail + npm ci --no-audit --no-fund + git init -q -b master && git add -A + git -c user.name=ci -c user.email=ci@example.com commit -qm init + npm run verify + # The one context for the template: green when its jobs passed or this change did not touch it. template: name: Template - needs: [template-changes, template-verify, template-local] + needs: [template-changes, template-verify, template-local, template-create] if: always() runs-on: ubuntu-latest timeout-minutes: 5 diff --git a/template/.github/workflows/ci.yml b/template/.github/workflows/ci.yml index 4379ae4..88f6f79 100644 --- a/template/.github/workflows/ci.yml +++ b/template/.github/workflows/ci.yml @@ -100,3 +100,19 @@ jobs: - name: Logs on failure if: failure() || cancelled() run: docker compose -f .agentage/compose.json logs --no-color --tail 80 || true + + # The one required context: green when every job passed or was skipped. + ci-required: + name: ci-required + needs: [verify, local] + if: always() + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Every job passed or was skipped + env: + NEEDS: ${{ toJSON(needs) }} + run: | + set -euo pipefail + jq -r 'to_entries[] | "\(.key): \(.value.result)"' <<<"$NEEDS" + jq -e 'all(.[]; .result == "success" or .result == "skipped")' <<<"$NEEDS" >/dev/null diff --git a/template/README.md b/template/README.md index 3eefe1c..ce71acc 100644 --- a/template/README.md +++ b/template/README.md @@ -63,16 +63,14 @@ Each part serves `/health` on port 3000 in its container. `up` does not publish ## What it serves -| Part | Folder | What it does | -| ------ | ----------------------- | -------------------------------------------------------------------------------- | -| pages | `src/pages` | `/` shows the id, version and commit | -| ui | `src/ui` | the widget `<{id}-echo>`, served at `/ui/{version}/{id}.js` | -| api | `src/api` | `GET /api/template/echo` (scope `{id}:read`), `GET /api/template/ping` (public) | -| mcp | `src/mcp` | the tool `{id}__echo` (scope `{id}:read`) | -| worker | `src/worker` | the job `tick`, every minute | -| store | `migrations/`, `seeds/` | postgres; `ping` counts the rows of `pings` | -| cli | `src/cli` | `agentage ping [msg]` prints `pong` | -| app | `src/app` | the shell page `/{id}`: an Echo button that calls the api through `useAppHost()` | +- pages, `src/pages`: `/` shows the id, version and commit. +- ui, `src/ui`: the widget `<{id}-echo>`, served at `/ui/{version}/{id}.js`. +- api, `src/api`: `GET /api/template/echo` (scope `{id}:read`) and `GET /api/template/ping` (public). +- mcp, `src/mcp`: the tool `{id}__echo` (scope `{id}:read`). +- worker, `src/worker`: the job `tick`, every minute. +- store, `migrations/` and `seeds/`: postgres; `ping` counts the rows of `pings`. +- cli, `src/cli`: `agentage ping [msg]` prints `pong`. +- app, `src/app`: the shell page `/{id}`: an Echo button that calls the api through `useAppHost()`. A seed in `seeds/` runs once, on an empty store. diff --git a/template/docs/run-locally.md b/template/docs/run-locally.md index 5087ef4..8a1afc9 100644 --- a/template/docs/run-locally.md +++ b/template/docs/run-locally.md @@ -21,12 +21,10 @@ in that folder, or find the holder with `docker ps`. ## Answers -| Call | Answer | -| ------------------------------------------- | -------------------------------------------------------------------------------------------- | -| `GET /api/template/echo?msg=hi` with token | 200 `{"success":true,"data":{"msg":"hi","caller":...}}` | -| `GET /api/template/ping` (public, no token) | 200 `{"success":true,"data":{"msg":"pong","pings":1}}`; `pings` counts the rows in the store | -| a protected route without a token | 401 `{"success":false,"error":{"code":"UNAUTHORIZED","message":...,"agcid":...}}` | -| `echo` without `msg` | 400 `{"success":false,"error":{"code":"VALIDATION_ERROR",...}}`, with the field named | +- `GET /api/template/echo?msg=hi` with a token: 200 `{"success":true,"data":{"msg":"hi","caller":...}}`. +- `GET /api/template/ping` (public, no token): 200 `{"success":true,"data":{"msg":"pong","pings":1}}`; `pings` counts the rows in the store. +- A protected route without a token: 401 `{"success":false,"error":{"code":"UNAUTHORIZED","message":...,"agcid":...}}`. +- `echo` without `msg`: 400 `{"success":false,"error":{"code":"VALIDATION_ERROR",...}}`, with the field named. Every answer has an `Agcid` response header with the request id. An error body also carries it as `error.agcid`. A success body does not. diff --git a/template/package.json b/template/package.json index 57a475e..821fbe2 100644 --- a/template/package.json +++ b/template/package.json @@ -63,7 +63,7 @@ "!dist/**/*.test.*" ], "scripts": { - "build": "tsc -p tsconfig.build.json && (test ! -d src/ui || agentage-widget bundle) && node node_modules/@agentage/extension/dist/tool/cli.js app", + "build": "tsc -p tsconfig.build.json && (test ! -d src/ui || agentage-widget bundle) && (test ! -d src/app || node node_modules/@agentage/extension/dist/tool/cli.js app)", "type-check": "tsc --noEmit -p tsconfig.eslint.json", "lint": "eslint .", "format": "prettier --write .", diff --git a/template/src/app/index.tsx b/template/src/app/index.tsx index 0ceb6af..1d111ea 100644 --- a/template/src/app/index.tsx +++ b/template/src/app/index.tsx @@ -4,6 +4,8 @@ import { Input } from '@agentage/design-system/input'; import { Label } from '@agentage/design-system/label'; import { useState } from 'react'; +const FIELD = 'template-msg'; + // The shell page of the extension: it reaches its own api through useAppHost().api, never fetch. export default function App() { const { api } = useAppHost(); @@ -20,8 +22,8 @@ export default function App() {

template

- - setMsg(e.target.value)} /> + + setMsg(e.target.value)} />