[agents] Support Rift Btrfs workspaces in worktree scripts

Automatically detect Rift Btrfs workspace environments in
create_worktree.sh and cleanup_worktree.sh. When running under Rift, use
rift subagent fork and rift subagent close (with fallback to standard
fork/close) instead of creating Git worktrees. Update v8-workflow skill
documentation accordingly.

Change-Id: I55ea398d6a6ff2c38e8a3a85ea4209612a6a7de9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7978998
Commit-Queue: Darius Mercadier <dmercadier@chromium.org>
Reviewed-by: Darius Mercadier <dmercadier@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#108156}
This commit is contained in:
Leszek Swirski authored and v8-scoped@luci-project-accounts.iam.gserviceaccount.com committed 2026-06-22 07:26:09 -07:00
1 parent 24298caa0b
commit d89c6024cf
3 files changed
+58 -5

No files matched your search

+19 -1
View File
@@ -10,12 +10,30 @@ if [ -z "$TASK_ID" ]; then
exit 1
fi
TOPLEVEL=$(git rev-parse --show-toplevel 2>/dev/null)
COMMON_DIR=$(git rev-parse --git-common-dir 2>/dev/null)
if [ -z "$COMMON_DIR" ]; then
if [ -z "$COMMON_DIR" ] || [ -z "$TOPLEVEL" ]; then
echo "Error: Not in a git repository."
exit 1
fi
V8_ROOT="$(cd "$COMMON_DIR/.." && pwd)"
WS_ROOT="$(dirname "$TOPLEVEL")"
if command -v rift >/dev/null 2>&1 && [ -f "$WS_ROOT/.rift_prime_directive.json" ]; then
CURRENT_WS="$(basename "$WS_ROOT")"
RIFT_PARENT_DIR="$(dirname "$WS_ROOT")"
if [[ "$TASK_ID" == "${CURRENT_WS}_subagent_"* ]] || [ -d "$RIFT_PARENT_DIR/$TASK_ID" ]; then
SUBAGENT_WS="$TASK_ID"
else
SUBAGENT_WS="${CURRENT_WS}_subagent_${TASK_ID}"
fi
if ! rift -y subagent close "$TASK_ID" > /dev/null 2>&1; then
rift close -y "$SUBAGENT_WS" > /dev/null 2>&1
fi
exit 0
fi
BRANCH_NAME="task-$TASK_ID"
WORKTREE_PATH="$V8_ROOT/worktrees/$BRANCH_NAME"
+32 -1
View File
@@ -8,12 +8,43 @@ if [ -z "$TASK_ID" ]; then
exit 1
fi
TOPLEVEL=$(git rev-parse --show-toplevel 2>/dev/null)
COMMON_DIR=$(git rev-parse --git-common-dir 2>/dev/null)
if [ -z "$COMMON_DIR" ]; then
if [ -z "$COMMON_DIR" ] || [ -z "$TOPLEVEL" ]; then
echo "Error: Not in a git repository."
exit 1
fi
V8_ROOT="$(cd "$COMMON_DIR/.." && pwd)"
WS_ROOT="$(dirname "$TOPLEVEL")"
if command -v rift >/dev/null 2>&1 && [ -f "$WS_ROOT/.rift_prime_directive.json" ]; then
CURRENT_WS="$(basename "$WS_ROOT")"
RIFT_PARENT_DIR="$(dirname "$WS_ROOT")"
REPO_DIR_NAME="$(basename "$TOPLEVEL")"
if [[ "$TASK_ID" == "${CURRENT_WS}_subagent_"* ]]; then
SUBAGENT_WS="$TASK_ID"
else
SUBAGENT_WS="${CURRENT_WS}_subagent_${TASK_ID}"
fi
WORKTREE_PATH="$RIFT_PARENT_DIR/$SUBAGENT_WS/$REPO_DIR_NAME"
if [ ! -d "$WORKTREE_PATH" ]; then
# Attempt Rift's subagent fork command as documented in the rift skill.
# Fallback to standard 'rift fork' if the subagent subcommand fails or is unsupported.
if ! rift -y subagent fork "$TASK_ID" > /dev/null 2>&1; then
rift fork -y "$SUBAGENT_WS" --no-build > /dev/null 2>&1
fi
fi
if [ ! -d "$WORKTREE_PATH" ]; then
echo "Error: Failed to create rift workspace $SUBAGENT_WS" >&2
exit 1
fi
echo "$WORKTREE_PATH"
exit 0
fi
BRANCH_NAME="task-$TASK_ID"
WORKTREE_PATH="$V8_ROOT/worktrees/$BRANCH_NAME"
+7 -3
View File
@@ -36,7 +36,11 @@ development:
## 3. Available Tools
- **[create_worktree.sh](../../scripts/create_worktree.sh)**: Automates the git
worktree isolation and setup process. Use this at the start of every new task.
- **[create_worktree.sh](../../scripts/create_worktree.sh)**: Automates task
isolation and setup. Automatically detects whether the repository is in a
standard Git checkout (creating a Git worktree) or a Rift Btrfs workspace
(forking an isolated Btrfs subvolume). Use this at the start of every new
task.
- **[cleanup_worktree.sh](../../scripts/cleanup_worktree.sh)**: Safely removes
task worktrees and prunes remnants once a CL is landed or abandoned.
task workspaces (Git worktrees or Rift subvolumes) and prunes remnants once a
CL is landed or abandoned.