|
| 1 | +# Upstream Sync Playbook |
| 2 | + |
| 3 | +## Baseline Snapshot (2026-02-05) |
| 4 | +- Upstream repo/branch: `anomalyco/opencode` `dev` |
| 5 | +- Fork repo/branch: `pRizz/opencode` `dev` |
| 6 | +- Merge base: `dac099a4892689d11abedb0fcc1098b50e0958c8` (source: `docs/upstream-sync/merge-base.txt`) |
| 7 | +- Fork commits ahead: 410 (source: `docs/upstream-sync/fork-commits.log`) |
| 8 | +- Upstream first-parent commits behind: 1307 (source: `docs/upstream-sync/upstream-first-parent.txt`) |
| 9 | +- Batch boundaries (every 200 commits): 6 (source: `docs/upstream-sync/boundary-commits.txt`) |
| 10 | + |
| 11 | +## Patchset Report |
| 12 | +- Fork commits: `docs/upstream-sync/fork-commits.log` |
| 13 | +- Range-diff: `docs/upstream-sync/range-diff.txt` |
| 14 | +- Upstream first-parent list: `docs/upstream-sync/upstream-first-parent.txt` |
| 15 | +- Boundary commits: `docs/upstream-sync/boundary-commits.txt` |
| 16 | + |
| 17 | +To regenerate: |
| 18 | +```bash |
| 19 | +git fetch upstream --tags |
| 20 | +git branch -f parent-dev upstream/dev |
| 21 | +git log --oneline parent-dev..dev > docs/upstream-sync/fork-commits.log |
| 22 | +git range-diff parent-dev...dev > docs/upstream-sync/range-diff.txt |
| 23 | +MERGE_BASE=$(git merge-base parent-dev dev) |
| 24 | +echo "$MERGE_BASE" > docs/upstream-sync/merge-base.txt |
| 25 | +git rev-list --first-parent ${MERGE_BASE}..parent-dev > docs/upstream-sync/upstream-first-parent.txt |
| 26 | +awk 'NR % 200 == 0 {print NR ":" $0}' docs/upstream-sync/upstream-first-parent.txt > docs/upstream-sync/boundary-commits.txt |
| 27 | +wc -l docs/upstream-sync/upstream-first-parent.txt > docs/upstream-sync/upstream-first-parent.count |
| 28 | +``` |
| 29 | + |
| 30 | +## Must-Keep Fork Areas (Verify and Extend) |
| 31 | +- `docs/docker-install-fork.md` (fork installation guidance) |
| 32 | +- `docs/README.md` references fork-specific usage |
| 33 | +- Any fork-only auth features or configuration paths (audit during conflict resolution) |
| 34 | + |
| 35 | +## Known Conflict Notes |
| 36 | +- None recorded yet. Add entries here as they appear during the merge train. |
| 37 | + |
| 38 | +## Merge Train Procedure (One-Time Catch-Up) |
| 39 | +1. Pause new work on `dev` until catch-up completes. |
| 40 | +2. Use `docs/upstream-sync/boundary-commits.txt` to select boundary commits. |
| 41 | +3. For each boundary commit: |
| 42 | + - Create a branch `sync/catchup-<n>` from `dev`. |
| 43 | + - Merge the boundary commit, resolve conflicts, and update this doc with resolutions. |
| 44 | + - Regenerate SDK artifacts if the SDK changes: `./packages/sdk/js/script/build.ts`. |
| 45 | + - Open a PR to `dev` labeled `sync` and merge after CI passes. |
| 46 | + |
| 47 | +## Ongoing Sync Automation |
| 48 | +- Script: `script/sync-upstream.ts` |
| 49 | +- Workflow: `.github/workflows/sync-upstream.yml` (runs every 3 hours) |
| 50 | +- Secrets required: `UPSTREAM_SYNC_TOKEN` (fine-grained PAT or GitHub App token) |
| 51 | +- Workflow behavior: |
| 52 | + - Updates `parent-dev` to match `upstream/dev` (force push). |
| 53 | + - Opens a sync PR when upstream is ahead. |
| 54 | + - Enables auto-merge once checks pass. |
| 55 | + - On conflict, opens an issue labeled `sync-conflict` with merge details. |
| 56 | + |
| 57 | +## Repo Settings Checklist |
| 58 | +- Enable auto-merge on the repository. |
| 59 | +- Require `test` and `typecheck` checks on `dev`. |
| 60 | +- Allow merge commits. |
| 61 | +- Ensure the PAT/App used by `UPSTREAM_SYNC_TOKEN` can create PRs, labels, and enable auto-merge. |
0 commit comments