# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: OpenAB Review Council (PAT)
spec:
    description: |
        PAT quickstart for a self-hosted, CodeRabbit-style PR-review council: a
        control plane + 3 stock OpenAB Claude pods deliberate on a PR and post one
        verdict as your GitHub account. After deploy, copy examples/pr-review.yml into
        the target repo and set COUNCIL_PLANE / COUNCIL_KEY. Do not also configure the
        webhook trigger on the same repo. See docs/template.md.
    icon: https://cdn-console.zeabur.com/f/6qNF8/ocp-icon.webp
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Control plane domain
          description: Public domain for the control plane's REST/SSE API.
        - key: CLAUDE_CODE_OAUTH_TOKEN
          type: PASSWORD
          name: Claude Code OAuth Token
          description: Agent auth for every pod. From `claude setup-token` (or use ANTHROPIC_API_KEY).
        - key: GH_TOKEN
          type: PASSWORD
          name: GitHub Token (chair only)
          description: Fine-grained PAT so the chair can comment/label/approve PRs.
    tags:
        - AI
        - Developer Tools
    readme: |
        # OpenAB Review Council (PAT)

        Use this template when you want the fastest install path: a copied GitHub
        Action triggers the council, and the chair posts the verdict with your
        fine-grained PAT.

        It deploys a control plane plus 3 stock OpenAB Claude pods (1 chair + 2
        reviewers). No per-bot setup is needed; every pod uses the same Claude Code
        OAuth token.

        ## Required variables

        - `PUBLIC_DOMAIN`: the control-plane domain, for example `my-council`.
        - `CLAUDE_CODE_OAUTH_TOKEN`: from `claude setup-token`.
        - `GH_TOKEN`: fine-grained PAT for the chair. Grant the target repo
          `Pull requests: Read and write` and `Contents: Read-only`.

        ## Install the copied Action

        1. Deploy this template and wait until `control-plane`, `chair`, `rev1`, and
           `rev2` are running.
        2. Open the `control-plane` service variables and copy `OABCP_API_KEY`; it is
           the generated `PASSWORD` value.
        3. Copy `examples/pr-review.yml` from the source repo into the target repo at
           `.github/workflows/pr-review.yml`:
           `https://github.com/canyugs/openab-control-plane/blob/main/examples/pr-review.yml`
        4. Set the target repo secrets:

           ```sh
           gh secret set COUNCIL_PLANE --body "https://my-council.zeabur.app"
           gh secret set COUNCIL_KEY --body "<OABCP_API_KEY>"
           ```

        ## Triggers

        - Automatic: PR opened, updated, reopened, or marked ready for review.
        - Manual: an OWNER / MEMBER / COLLABORATOR comments `/review` on the PR.
        - Manual fallback: run the copied workflow with `workflow_dispatch` and a PR
          number.

        The chair posts one verdict comment as the PAT owner.

        ## Verify

        1. Open or update a PR in the target repo.
        2. Confirm the target repo's `Council Review` GitHub Action succeeds.
        3. Check the PR for one council verdict comment.
        4. If there is no verdict, check the `control-plane` and `chair` service logs.

        Use this PAT template or the GitHub App webhook template, not both on one repo,
        or one PR event can convene two councils.

        For private repos, reviewer pods also need read access to fetch the PR diff.
        Public repos work anonymously. Full guide:
        `https://github.com/canyugs/openab-control-plane/blob/main/docs/template.md`
    services:
        - name: control-plane
          icon: https://cdn-console.zeabur.com/f/6qNF8/ocp-icon.webp
          template: PREBUILT_V2
          spec:
            id: control-plane
            source:
                image: docker.io/canyu/openab-control-plane:0.1.11
            ports:
                - id: web
                  port: 8090
                  type: HTTP
            volumes:
                - id: data
                  dir: /data
            env:
                OABCP_ADDR:
                    default: 0.0.0.0:8090
                OABCP_API_KEY:
                    default: ${PASSWORD}
                    expose: true
                OABCP_BOTS:
                    default: chair:chair,rev1:reviewer,rev2:reviewer
                OABCP_DB:
                    default: /data/plane.db
                OABCP_WS_URL:
                    default: ws://control-plane.zeabur.internal:8090/ws
            healthCheck:
                type: HTTP
                port: web
                http:
                    path: /healthz
          domainKey: PUBLIC_DOMAIN
        - name: chair
          icon: https://cdn-console.zeabur.com/f/0Ewi6/openab-icon.webp
          dependencies:
            - control-plane
          template: PREBUILT_V2
          spec:
            id: chair
            source:
                image: ghcr.io/openabdev/openab:0.9.0-beta.3-claude
                command:
                    - openab
                    - run
                    - -c
                    - http://control-plane.zeabur.internal:8090/bot-config/chair
            volumes:
                - id: home
                  dir: /home/node
            env:
                CLAUDE_CODE_OAUTH_TOKEN:
                    default: ${CLAUDE_CODE_OAUTH_TOKEN}
                GH_TOKEN:
                    default: ${GH_TOKEN}
        - name: rev1
          icon: https://cdn-console.zeabur.com/f/0Ewi6/openab-icon.webp
          dependencies:
            - control-plane
          template: PREBUILT_V2
          spec:
            id: rev1
            source:
                image: ghcr.io/openabdev/openab:0.9.0-beta.3-claude
                command:
                    - openab
                    - run
                    - -c
                    - http://control-plane.zeabur.internal:8090/bot-config/rev1
            env:
                CLAUDE_CODE_OAUTH_TOKEN:
                    default: ${CLAUDE_CODE_OAUTH_TOKEN}
        - name: rev2
          icon: https://cdn-console.zeabur.com/f/0Ewi6/openab-icon.webp
          dependencies:
            - control-plane
          template: PREBUILT_V2
          spec:
            id: rev2
            source:
                image: ghcr.io/openabdev/openab:0.9.0-beta.3-claude
                command:
                    - openab
                    - run
                    - -c
                    - http://control-plane.zeabur.internal:8090/bot-config/rev2
            env:
                CLAUDE_CODE_OAUTH_TOKEN:
                    default: ${CLAUDE_CODE_OAUTH_TOKEN}
