From cb2f2dd621d57c7f442d4facc6d8e81cd08b5009 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 26 Jun 2026 04:40:34 +0000 Subject: [PATCH 1/5] chore: add agent rule to base new branches on upstream/main Add a workspace-specific agent rule to ensure that new conversations/sessions and branches are always based on the latest upstream code to avoid using outdated code states. --- .agents/rules/workspace.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .agents/rules/workspace.md diff --git a/.agents/rules/workspace.md b/.agents/rules/workspace.md new file mode 100644 index 0000000000..4159cc5ebe --- /dev/null +++ b/.agents/rules/workspace.md @@ -0,0 +1,15 @@ +--- +trigger: always_on +--- + +# Workspace Rules + +To avoid confusion from using outdated code states, when starting a new +conversation/session or when first starting a new branch or worktree, unless +explicitly instructed otherwise, ensure the latest upstream code is used as the +basis: +* Fetch `upstream/main` (`git fetch upstream main`). +* Base any new branch or worktree upon `upstream/main` (e.g., + `git checkout -b upstream/main`). +* Set the upstream branch to `upstream/main` + (`git branch --set-upstream-to=upstream/main`). From 663b4b23dbdbc86e48e388557ca870c4e4eb11ab Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 26 Jun 2026 04:53:19 +0000 Subject: [PATCH 2/5] chore: add agent rule and setup script for upstream tracking Add a workspace-specific agent rule and a helper script to ensure new conversations/sessions and branches are based on the latest upstream code and track it safely. --- .agents/rules/workspace.md | 7 +++++-- .agents/scripts/setup_upstream.sh | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 .agents/scripts/setup_upstream.sh diff --git a/.agents/rules/workspace.md b/.agents/rules/workspace.md index 4159cc5ebe..c2727f2f4a 100644 --- a/.agents/rules/workspace.md +++ b/.agents/rules/workspace.md @@ -11,5 +11,8 @@ basis: * Fetch `upstream/main` (`git fetch upstream main`). * Base any new branch or worktree upon `upstream/main` (e.g., `git checkout -b upstream/main`). -* Set the upstream branch to `upstream/main` - (`git branch --set-upstream-to=upstream/main`). +* Run the workspace helper script to configure upstream tracking and safe + pushing: + ```bash + .agents/scripts/setup_upstream.sh + ``` diff --git a/.agents/scripts/setup_upstream.sh b/.agents/scripts/setup_upstream.sh new file mode 100755 index 0000000000..b6bdc2bb20 --- /dev/null +++ b/.agents/scripts/setup_upstream.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Helper script to set up upstream tracking for fork-and-PR workflow. +set -e + +# Detect current branch if not provided as argument +BRANCH_NAME="${1:-$(git symbolic-ref --short HEAD)}" + +if [ -z "$BRANCH_NAME" ]; then + echo "Error: Could not detect current branch name." >&2 + exit 1 +fi + +echo "Setting up upstream tracking for branch: $BRANCH_NAME" + +# 1. Set the pull/fetch behavior to track the canonical repo's main branch +git config --local "branch.${BRANCH_NAME}.remote" upstream +git config --local "branch.${BRANCH_NAME}.merge" refs/heads/main + +# 2. Override the destination remote for pushing +git config --local "branch.${BRANCH_NAME}.pushRemote" origin + +# 3. Defend against global push.default settings (ensure it pushes to current branch name) +git config --local push.default current + +echo "Successfully configured upstream/main tracking and origin pushRemote for $BRANCH_NAME!" From 5a4337765b6213858fd9a75fb4fc13b795d9bea4 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 26 Jun 2026 04:54:29 +0000 Subject: [PATCH 3/5] chore: rename helper script to setup_triangle_branch.sh Rename the upstream tracking helper script to setup_triangle_branch.sh to better reflect the triangular Git workflow, and update the workspace rules accordingly. --- .agents/rules/workspace.md | 2 +- .agents/scripts/{setup_upstream.sh => setup_triangle_branch.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .agents/scripts/{setup_upstream.sh => setup_triangle_branch.sh} (100%) diff --git a/.agents/rules/workspace.md b/.agents/rules/workspace.md index c2727f2f4a..b819925f83 100644 --- a/.agents/rules/workspace.md +++ b/.agents/rules/workspace.md @@ -14,5 +14,5 @@ basis: * Run the workspace helper script to configure upstream tracking and safe pushing: ```bash - .agents/scripts/setup_upstream.sh + .agents/scripts/setup_triangle_branch.sh ``` diff --git a/.agents/scripts/setup_upstream.sh b/.agents/scripts/setup_triangle_branch.sh similarity index 100% rename from .agents/scripts/setup_upstream.sh rename to .agents/scripts/setup_triangle_branch.sh From 2dc051f58818608a86a619094123be70fab60ee6 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 26 Jun 2026 04:56:56 +0000 Subject: [PATCH 4/5] chore: rename helper script to create_triangle_branch.sh Rename the upstream tracking helper script to create_triangle_branch.sh to better align with branch creation terminology, and update the workspace rules. --- .agents/rules/workspace.md | 2 +- .../{setup_triangle_branch.sh => create_triangle_branch.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .agents/scripts/{setup_triangle_branch.sh => create_triangle_branch.sh} (100%) diff --git a/.agents/rules/workspace.md b/.agents/rules/workspace.md index b819925f83..882c9e29f3 100644 --- a/.agents/rules/workspace.md +++ b/.agents/rules/workspace.md @@ -14,5 +14,5 @@ basis: * Run the workspace helper script to configure upstream tracking and safe pushing: ```bash - .agents/scripts/setup_triangle_branch.sh + .agents/scripts/create_triangle_branch.sh ``` diff --git a/.agents/scripts/setup_triangle_branch.sh b/.agents/scripts/create_triangle_branch.sh similarity index 100% rename from .agents/scripts/setup_triangle_branch.sh rename to .agents/scripts/create_triangle_branch.sh From 8510760545fe5ead77d745587ad30dbc7bd61ce0 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 26 Jun 2026 04:58:54 +0000 Subject: [PATCH 5/5] chore: rename helper script to setup_triangle_branch.sh Rename the upstream tracking helper script back to setup_triangle_branch.sh to align with preferred naming, and update the workspace rules. --- .agents/rules/workspace.md | 2 +- .../{create_triangle_branch.sh => setup_triangle_branch.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .agents/scripts/{create_triangle_branch.sh => setup_triangle_branch.sh} (100%) diff --git a/.agents/rules/workspace.md b/.agents/rules/workspace.md index 882c9e29f3..b819925f83 100644 --- a/.agents/rules/workspace.md +++ b/.agents/rules/workspace.md @@ -14,5 +14,5 @@ basis: * Run the workspace helper script to configure upstream tracking and safe pushing: ```bash - .agents/scripts/create_triangle_branch.sh + .agents/scripts/setup_triangle_branch.sh ``` diff --git a/.agents/scripts/create_triangle_branch.sh b/.agents/scripts/setup_triangle_branch.sh similarity index 100% rename from .agents/scripts/create_triangle_branch.sh rename to .agents/scripts/setup_triangle_branch.sh