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
44 changes: 43 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions template/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 8 additions & 10 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 4 additions & 6 deletions template/docs/run-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
6 changes: 4 additions & 2 deletions template/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -20,8 +22,8 @@ export default function App() {
<section className="flex max-w-xl flex-col gap-4 p-6">
<h1 className="text-xl font-semibold">template</h1>
<div className="flex flex-col gap-2">
<Label htmlFor="template-msg">Message</Label>
<Input id="template-msg" value={msg} onChange={(e) => setMsg(e.target.value)} />
<Label htmlFor={FIELD}>Message</Label>
<Input id={FIELD} value={msg} onChange={(e) => setMsg(e.target.value)} />
</div>
<Button onClick={() => void ping()}>Echo</Button>
<p aria-live="polite" className="min-h-6">
Expand Down
Loading