Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ and a few `agent-branch-start` runs:

```text
GuardeX (your preferred local branch: main/dev)
agent_codex_<timestamp>-<snapshot>-<task>
agent_bot_<timestamp>-<snapshot>-<task>
agent_bot_<timestamp>-<snapshot>-<task>
agent_codex_<snapshot>-<task>
agent_bot_<snapshot>-<task>
agent_bot_<snapshot>-<task>-2
```

That gives you one stable main repo view plus parallel agent worktrees in the
Expand Down
14 changes: 8 additions & 6 deletions scripts/agent-branch-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,17 @@ snapshot_name="$(resolve_active_codex_snapshot_name)"
snapshot_slug="$(sanitize_slug "$snapshot_name" "")"
timestamp="$(date +%Y%m%d-%H%M%S)"
if [[ -n "$snapshot_slug" ]]; then
branch_name="agent/${agent_slug}/${timestamp}-${snapshot_slug}-${task_slug}"
branch_name_base="agent/${agent_slug}/${snapshot_slug}-${task_slug}"
else
branch_name="agent/${agent_slug}/${timestamp}-${task_slug}"
branch_name_base="agent/${agent_slug}/${task_slug}"
fi

if git show-ref --verify --quiet "refs/heads/${branch_name}"; then
echo "[agent-branch-start] Branch already exists: ${branch_name}" >&2
exit 1
fi
branch_name="$branch_name_base"
branch_suffix=2
while git show-ref --verify --quiet "refs/heads/${branch_name}"; do
branch_name="${branch_name_base}-${branch_suffix}"
branch_suffix=$((branch_suffix + 1))
done

if [[ "$WORKTREE_MODE" -eq 0 ]]; then
if [[ "$ALLOW_IN_PLACE" -ne 1 ]]; then
Expand Down
14 changes: 8 additions & 6 deletions templates/scripts/agent-branch-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,17 @@ snapshot_name="$(resolve_active_codex_snapshot_name)"
snapshot_slug="$(sanitize_slug "$snapshot_name" "")"
timestamp="$(date +%Y%m%d-%H%M%S)"
if [[ -n "$snapshot_slug" ]]; then
branch_name="agent/${agent_slug}/${timestamp}-${snapshot_slug}-${task_slug}"
branch_name_base="agent/${agent_slug}/${snapshot_slug}-${task_slug}"
else
branch_name="agent/${agent_slug}/${timestamp}-${task_slug}"
branch_name_base="agent/${agent_slug}/${task_slug}"
fi

if git show-ref --verify --quiet "refs/heads/${branch_name}"; then
echo "[agent-branch-start] Branch already exists: ${branch_name}" >&2
exit 1
fi
branch_name="$branch_name_base"
branch_suffix=2
while git show-ref --verify --quiet "refs/heads/${branch_name}"; do
branch_name="${branch_name_base}-${branch_suffix}"
branch_suffix=$((branch_suffix + 1))
done

if [[ "$WORKTREE_MODE" -eq 0 ]]; then
if [[ "$ALLOW_IN_PLACE" -ne 1 ]]; then
Expand Down
4 changes: 2 additions & 2 deletions test/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ OUT
{ env: { PATH: `${fakeBin}:${process.env.PATH || ''}` } },
);
assert.equal(result.status, 0, result.stderr || result.stdout);
assert.match(result.stdout, /Created branch: agent\/planner\/\d{8}-\d{6}-zeus-edix-hu-restore-snapshot/);
assert.match(result.stdout, /Created branch: agent\/planner\/zeus-edix-hu-restore-snapshot(?:-\d+)?/);
});

test('setup agent-branch-start supports explicit snapshot override without codex-auth', () => {
Expand All @@ -491,7 +491,7 @@ test('setup agent-branch-start supports explicit snapshot override without codex
{ env: { MUSAFETY_CODEX_AUTH_SNAPSHOT: 'Prod Snapshot One' } },
);
assert.equal(result.status, 0, result.stderr || result.stdout);
assert.match(result.stdout, /Created branch: agent\/bot\/\d{8}-\d{6}-prod-snapshot-one-ship-fix/);
assert.match(result.stdout, /Created branch: agent\/bot\/prod-snapshot-one-ship-fix(?:-\d+)?/);
});

test('setup agent-branch-start defaults base to current branch and stores per-branch base metadata', () => {
Expand Down
Loading