From b340e8066742e44518f6b6941c07517e4d97eaa8 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 29 Apr 2026 13:59:26 +0300 Subject: [PATCH 1/2] scripts : add wc2wt.sh - create worktree from current HEAD Add a script to create a git worktree on a new branch from the current HEAD. Similar to pr2wt.sh but for local development branches instead of PRs. Usage: ./scripts/wc2wt.sh gg/new-feature ./scripts/wc2wt.sh gg/new-feature "bash -l" Assisted-by: llama.cpp:local pi --- scripts/wc2wt.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 scripts/wc2wt.sh diff --git a/scripts/wc2wt.sh b/scripts/wc2wt.sh new file mode 100755 index 00000000000..ab76c841d45 --- /dev/null +++ b/scripts/wc2wt.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# initialize a new worktree from a branch name: +# +# - creates a new branch from current HEAD +# - creates a new worktree in a parent folder, suffixed with the branch name +# +# sample usage: +# ./scripts/wc2wt.sh gg/new-feature-foo-bar +# ./scripts/wc2wt.sh gg/new-feature-foo-bar opencode +# ./scripts/wc2wt.sh gg/new-feature-foo-bar "cmake -B build && cmake --build build" +# ./scripts/wc2wt.sh gg/new-feature-foo-bar "bash -l" + +function usage() { + echo "usage: $0 [cmd]" + exit 1 +} + +# check we are in the right directory +if [[ ! -f "scripts/wc2wt.sh" ]]; then + echo "error: this script must be run from the root of the repository" + exit 1 +fi + +if [[ $# -lt 1 || $# -gt 2 ]]; then + usage +fi + +BRANCH=$1 + +if [[ -z "$BRANCH" ]]; then + echo "error: branch name must not be empty" + exit 1 +fi + +dir=$(basename $(pwd)) +# sanitize branch name for directory name (replace / with -) +dir_suffix=$(echo "$BRANCH" | tr '/' '-') + +git branch -D "$BRANCH" 2> /dev/null +git worktree add -b "$BRANCH" "../$dir-$dir_suffix" HEAD + +og_path=$(pwd) +wt_path=$(cd "../$dir-$dir_suffix" && pwd) + +echo "git worktree created in $wt_path" + +cd "$wt_path" + +# pi agent setup in the worktree +if [[ -f "$og_path/.pi/SYSTEM.md" && ! -f ".pi/SYSTEM.md" ]]; then + mkdir -p .pi + ln -sfn "$og_path/.pi/SYSTEM.md" .pi/SYSTEM.md +fi + +if [[ $# -eq 2 ]]; then + echo "executing: $2" + eval "$2" +fi From 22b48a947b6bcf01c339ad673292106ac5eee089 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 29 Apr 2026 14:34:28 +0300 Subject: [PATCH 2/2] cont : no need to try to delete the branch --- scripts/wc2wt.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/wc2wt.sh b/scripts/wc2wt.sh index ab76c841d45..157881b458f 100755 --- a/scripts/wc2wt.sh +++ b/scripts/wc2wt.sh @@ -37,7 +37,6 @@ dir=$(basename $(pwd)) # sanitize branch name for directory name (replace / with -) dir_suffix=$(echo "$BRANCH" | tr '/' '-') -git branch -D "$BRANCH" 2> /dev/null git worktree add -b "$BRANCH" "../$dir-$dir_suffix" HEAD og_path=$(pwd)