name: computer-use sync reminder

# When a merge to main touches the vendored Linux Computer Use crate, open (or
# update) an issue so the change can be propagated to the standalone
# agent-sh/computer-use-linux repo. Version-number parity between the two crates
# is the coordination signal; this makes the reminder explicit so the numbers do
# not silently drift apart.

on:
  push:
    branches: [main]
    paths:
      - 'computer-use-linux/**'

permissions:
  contents: read
  issues: write

jobs:
  remind:
    name: open sync reminder
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            const label = 'computer-use-sync';
            const otherRepo = 'agent-sh/computer-use-linux';
            const compare = context.payload.compare || '';
            const sha = context.sha.slice(0, 8);
            const body = [
              'A merge to `main` touched `computer-use-linux/**` (the vendored Linux Computer Use crate).',
              '',
              `Propagate the change to **${otherRepo}** if it is not codex-specific glue.`,
              'Keep the upstream generic naming there — do **not** push `codex-*` /',
              '`CODEX_COMPUTER_USE_*` names, `identity.rs`, or the chrome-extension host upstream.',
              '',
              `- Compare: ${compare || sha}`,
              `- Triggering commit: ${context.sha}`,
              '',
              'Once synced, bump both crates to the same enumeration. A version mismatch',
              'between this crate and the standalone one means a sync is still pending.',
            ].join('\n');
            try {
              await github.rest.issues.getLabel({ ...context.repo, name: label });
            } catch (e) {
              await github.rest.issues.createLabel({
                ...context.repo,
                name: label,
                color: 'fbca04',
                description: 'Pending Linux Computer Use sync to the other repo',
              });
            }
            const existing = await github.rest.issues.listForRepo({
              ...context.repo,
              state: 'open',
              labels: label,
              per_page: 1,
            });
            if (existing.data.length > 0) {
              await github.rest.issues.createComment({
                ...context.repo,
                issue_number: existing.data[0].number,
                body,
              });
            } else {
              await github.rest.issues.create({
                ...context.repo,
                title: 'Sync Linux Computer Use → agent-sh/computer-use-linux',
                labels: [label],
                body,
              });
            }
