name: opencode-plugin checks

# On PRs this is invoked by ci-gate.yml (the single required check);
# push-to-main and manual runs remain standalone.
on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - 'integrations/mem0-plugin/.opencode-plugin/**'
      - '.github/workflows/opencode-plugin-checks.yml'
  workflow_call:

jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: integrations/mem0-plugin/.opencode-plugin
    steps:
      - uses: actions/checkout@v4

      - name: Install Bun
        uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install dependencies
        run: bun install --frozen-lockfile

      - name: Type check
        run: bun run type-check

      - name: Build
        run: bun run build

      - name: Verify dist output exists
        run: |
          test -f dist/index.js || (echo "Build output missing: dist/index.js" && exit 1)
