name: CI

on:
  push:
    branches: [main]
  pull_request:

# Least privilege: CI only reads the repo and runs tests.
permissions:
  contents: read

jobs:
  test:
    name: test (node ${{ matrix.node }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        node: ['18', '20', '22']
    steps:
      - uses: actions/checkout@v4

      - name: Use Node.js ${{ matrix.node }}
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node }}
          cache: 'npm'

      - run: npm ci

      - name: Syntax check
        run: node --check src/index.js

      - name: Build
        run: npm run build

      - name: Unit and wire tests
        run: npm run test:unit

      - name: MCP smoke (initialize + tools/list)
        run: node .github/smoke.mjs
