docs/UPSTREAM_STRATEGY.md
Fork: topoffunnel/CodexBar
Upstream 1: steipete/CodexBar (original)
Upstream 2: nguyenphutrong/quotio (inspiration source)
# Your fork (origin)
git remote add origin [email protected]:topoffunnel/CodexBar.git
# Original upstream (steipete)
git remote add upstream [email protected]:steipete/CodexBar.git
# Quotio inspiration source
git remote add quotio [email protected]:nguyenphutrong/quotio.git
# Verify remotes
git remote -v
main (your fork's stable branch)
āāā feature/* (fork-specific features)
āāā upstream-sync/* (tracking upstream changes)
āāā quotio-inspired/* (features inspired by quotio)
āāā upstream-pr/* (branches for upstream PRs)
Branch Types:
main - Your fork's stable release branchfeature/* - Fork-specific developmentupstream-sync/* - Temporary branches for reviewing upstream changesquotio-inspired/* - Features adapted from quotio patternsupstream-pr/* - Clean branches for upstream contributions#!/bin/bash
# Scripts/check_upstreams.sh
echo "==> Fetching upstream changes..."
git fetch upstream
git fetch quotio
echo ""
echo "==> Upstream (steipete) changes:"
git log --oneline main..upstream/main --no-merges | head -20
echo ""
echo "==> Quotio changes:"
git log --oneline --all --remotes=quotio/main --since="1 week ago" | head -20
echo ""
echo "==> Files changed in upstream:"
git diff --stat main..upstream/main
echo ""
echo "==> Files changed in quotio (recent):"
git diff --stat quotio/main~10..quotio/main
Create .github/workflows/upstream-monitor.yml:
name: Monitor Upstreams
on:
schedule:
- cron: '0 9 * * 1,4' # Monday and Thursday at 9 AM
workflow_dispatch:
jobs:
check-upstream:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Add upstream remotes
run: |
git remote add upstream https://github.com/steipete/CodexBar.git
git remote add quotio https://github.com/nguyenphutrong/quotio.git
git fetch upstream
git fetch quotio
- name: Check for new commits
id: check
run: |
UPSTREAM_NEW=$(git log --oneline main..upstream/main --no-merges | wc -l)
QUOTIO_NEW=$(git log --oneline --all --remotes=quotio/main --since="1 week ago" | wc -l)
echo "upstream_commits=$UPSTREAM_NEW" >> $GITHUB_OUTPUT
echo "quotio_commits=$QUOTIO_NEW" >> $GITHUB_OUTPUT
- name: Create issue if changes detected
if: steps.check.outputs.upstream_commits > 0 || steps.check.outputs.quotio_commits > 0
uses: actions/github-script@v7
with:
script: |
const upstreamCommits = '${{ steps.check.outputs.upstream_commits }}';
const quotioCommits = '${{ steps.check.outputs.quotio_commits }}';
const body = `## Upstream Changes Detected
**steipete/CodexBar:** ${upstreamCommits} new commits
**quotio:** ${quotioCommits} new commits (last week)
Review changes:
- [steipete commits](https://github.com/steipete/CodexBar/compare/main...upstream/main)
- [quotio commits](https://github.com/nguyenphutrong/quotio/commits/main)
Run \`./Scripts/review_upstream.sh\` to analyze changes.`;
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Upstream Changes Available',
body: body,
labels: ['upstream-sync']
});
#!/bin/bash
# Scripts/review_upstream.sh
UPSTREAM=${1:-upstream} # 'upstream' or 'quotio'
echo "==> Creating review branch for $UPSTREAM..."
git checkout main
git checkout -b upstream-sync/$UPSTREAM-$(date +%Y%m%d)
echo "==> Fetching latest..."
git fetch $UPSTREAM
echo "==> Showing commits to review:"
git log --oneline --graph main..$UPSTREAM/main | head -30
echo ""
echo "==> Detailed diff:"
git diff main..$UPSTREAM/main --stat
echo ""
echo "Next steps:"
echo "1. Review commits: git log -p main..$UPSTREAM/main"
echo "2. Cherry-pick specific commits: git cherry-pick <commit-hash>"
echo "3. Or merge all: git merge $UPSTREAM/main"
echo "4. Test thoroughly"
echo "5. Merge to main: git checkout main && git merge upstream-sync/$UPSTREAM-$(date +%Y%m%d)"
# Review individual commits
git log -p main..upstream/main
# Cherry-pick specific valuable commits
git cherry-pick <commit-hash>
# If conflicts, resolve and continue
git cherry-pick --continue
# Or abort if not suitable
git cherry-pick --abort
# Create inspiration branch
git checkout -b quotio-inspired/feature-name
# View quotio implementation (read-only)
git show quotio/main:path/to/file.swift
# Implement similar pattern in your codebase
# (write your own code, don't copy)
# Commit with attribution
git commit -m "feat: implement feature inspired by quotio
Inspired by quotio's approach to [feature]:
https://github.com/nguyenphutrong/quotio/commit/abc123
Implemented independently with CodexBar-specific patterns."
ā Good for Upstream:
ā Keep in Fork:
#!/bin/bash
# Scripts/prepare_upstream_pr.sh
FEATURE_NAME=$1
if [ -z "$FEATURE_NAME" ]; then
echo "Usage: ./Scripts/prepare_upstream_pr.sh <feature-name>"
exit 1
fi
echo "==> Creating upstream PR branch..."
git checkout upstream/main
git checkout -b upstream-pr/$FEATURE_NAME
echo "==> Branch created: upstream-pr/$FEATURE_NAME"
echo ""
echo "Next steps:"
echo "1. Cherry-pick your commits (without fork branding)"
echo "2. Remove any fork-specific code"
echo "3. Ensure tests pass"
echo "4. Push: git push origin upstream-pr/$FEATURE_NAME"
echo "5. Create PR to steipete/CodexBar from GitHub UI"
# Start from upstream's main
git checkout upstream/main
git checkout -b upstream-pr/fix-cursor-bonus
# Cherry-pick your fix (without fork branding)
git cherry-pick <your-commit-hash>
# If commit includes fork branding, amend it
git commit --amend
# Remove fork-specific changes
git reset HEAD~1
# Manually stage only upstream-suitable changes
git add <files>
git commit -m "fix: correct Cursor bonus credits calculation
Fixes issue where bonus credits were incorrectly calculated.
Tested with multiple account types."
# Push to your fork
git push origin upstream-pr/fix-cursor-bonus
# Create PR to steipete/CodexBar via GitHub UI
feat: add multi-account management for Augment
Implements account switching UI and storage.
Fork-specific feature for topoffunnel.com users.
Co-authored-by: Brandon Charleson <[email protected]>
fix: correct Cursor bonus credits calculation
The bonus credits were being added instead of subtracted
from the total usage calculation.
Tested with Pro and Team accounts.
feat: implement session persistence inspired by quotio
Adds automatic session restoration on app restart.
Inspired by quotio's approach:
https://github.com/nguyenphutrong/quotio/blob/main/...
Implemented independently using CodexBar patterns.
| Change Type | Fork | Upstream | Notes |
|---|---|---|---|
| Bug fix (universal) | ā | ā | Submit to upstream |
| Bug fix (fork-specific) | ā | ā | Keep in fork |
| Performance improvement | ā | ā | Submit to upstream |
| New provider support | ā | ā | Submit to upstream |
| Provider enhancement | ā | Maybe | Depends on scope |
| UI improvement (generic) | ā | ā | Submit to upstream |
| UI improvement (fork brand) | ā | ā | Keep in fork |
| Multi-account feature | ā | ā | Too large for upstream |
| Documentation | ā | ā | Submit to upstream |
| Tests | ā | ā | Submit to upstream |
| Fork branding | ā | ā | Never upstream |
| Experimental feature | ā | ā | Prove it first |
# Make changes in feature branch
git checkout -b feature/my-improvement
# Commit 1: Core improvement (upstream-suitable)
git add Sources/CodexBarCore/...
git commit -m "feat: improve cookie handling"
# Commit 2: Fork-specific enhancements
git add Sources/CodexBar/About.swift
git commit -m "feat: add fork attribution for improvement"
# Merge to main (both commits)
git checkout main
git merge feature/my-improvement
# For upstream PR: cherry-pick only commit 1
git checkout upstream/main
git checkout -b upstream-pr/cookie-handling
git cherry-pick <commit-1-hash> # Only the core improvement
Keep these files fork-specific (never upstream):
Sources/CodexBar/About.swift (your attribution)Sources/CodexBar/PreferencesAboutPane.swift (fork sections)README.md (fork notice)docs/FORK_*.md (fork documentation)FORK_STATUS.mdAll automation scripts are located in Scripts/:
GitHub Actions workflow: .github/workflows/upstream-monitor.yml
# Monday morning routine
./Scripts/check_upstreams.sh
# If changes found, review them
./Scripts/review_upstream.sh upstream
# Cherry-pick valuable commits
git cherry-pick abc123
git cherry-pick def456
# Test
./Scripts/compile_and_run.sh
# Merge to main
git checkout main
git merge upstream-sync/upstream-20260104
# You fixed a bug in your fork
git log --oneline -5
# abc123 fix: correct Cursor bonus credits
# def456 feat: add fork attribution
# Prepare upstream PR (only the fix, not attribution)
./Scripts/prepare_upstream_pr.sh fix-cursor-bonus
# Cherry-pick only the fix
git cherry-pick abc123
# Review - ensure no fork branding
git diff upstream/main
# Push and create PR
git push origin upstream-pr/fix-cursor-bonus
# Then create PR on GitHub to steipete/CodexBar
# Analyze quotio
./Scripts/analyze_quotio.sh
# Review their multi-account implementation
git show quotio/main:path/to/AccountManager.swift
# Document patterns in docs/QUOTIO_ANALYSIS.md
# Then implement independently in your fork
# Commit with attribution
git commit -m "feat: implement multi-account management
Inspired by quotio's account switching pattern:
https://github.com/nguyenphutrong/quotio/...
Implemented independently using CodexBar's architecture."
# During upstream merge
git merge upstream/main
# CONFLICT in Sources/CodexBar/About.swift
# Keep your fork version for branding files
git checkout --ours Sources/CodexBar/About.swift
git add Sources/CodexBar/About.swift
# Merge other files manually
# Then continue
git commit
# Oops! Pushed fork branding to upstream PR branch
git checkout upstream-pr/my-feature
# Reset to before the bad commit
git reset --hard HEAD~1
# Re-apply changes without branding
# ... make changes ...
git commit -m "fix: proper commit"
# Force push (only safe on PR branches)
git push origin upstream-pr/my-feature --force
# See what you've merged from upstream
git log --oneline --graph --all --grep="upstream"
# See what's still pending
git log --oneline main..upstream/main
# Create a tracking branch
git checkout -b upstream-tracking upstream/main
git log --oneline upstream-tracking..main
./Scripts/check_upstreams.sh)./Scripts/analyze_quotio.sh)Remember: Your fork is independent. Upstream contributions are optional. Learn from others, but implement independently. Credit sources appropriately.