From 04571ad0897e113cf58dcddd25ab2496c5a0a3d3 Mon Sep 17 00:00:00 2001 From: Moritz Bierling Date: Mon, 17 Nov 2025 12:45:31 +0000 Subject: [PATCH] feat: add Droid AI adapter and Zsh completion support - Add Droid AI adapter (adapters/ai/droid.sh) following existing adapter pattern - Add gtr.zsh completion file for Zsh shell support - Enables 'gtr ai' command to launch Droid in worktrees - Provides tab completion for all gtr commands in Zsh Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- adapters/ai/droid.sh | 26 ++++++++++++++ completions/gtr.zsh | 81 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 adapters/ai/droid.sh create mode 100644 completions/gtr.zsh diff --git a/adapters/ai/droid.sh b/adapters/ai/droid.sh new file mode 100644 index 0000000..4706c85 --- /dev/null +++ b/adapters/ai/droid.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Droid AI adapter + +# Check if Droid is available +ai_can_start() { + command -v droid >/dev/null 2>&1 +} + +# Start Droid in a directory +# Usage: ai_start path [args...] +ai_start() { + local path="$1" + shift + + if ! ai_can_start; then + log_error "Droid not found. Install from https://github.com/factory-droid/droid" + return 1 + fi + + if [ ! -d "$path" ]; then + log_error "Directory not found: $path" + return 1 + fi + + (cd "$path" && droid "$@") +} diff --git a/completions/gtr.zsh b/completions/gtr.zsh new file mode 100644 index 0000000..900a908 --- /dev/null +++ b/completions/gtr.zsh @@ -0,0 +1,81 @@ +#!/usr/bin/env zsh +# Zsh completion for gtr + +# Load the completion function +_gtr() { + local -a commands + commands=( + 'new:Create a new worktree' + 'go:Navigate to worktree' + 'rm:Remove worktree(s)' + 'editor:Open worktree in editor' + 'ai:Start AI coding tool' + 'ls:List all worktrees' + 'list:List all worktrees' + 'clean:Remove stale worktrees' + 'doctor:Health check' + 'adapter:List available adapters' + 'config:Manage configuration' + 'version:Show version' + 'help:Show help' + ) + + local -a branches all_options + # Get branch names + branches=(${(f)"$(git branch --format='%(refname:short)' 2>/dev/null)"}) + # Add special ID '1' for main repo + all_options=("1" "${branches[@]}") + + if (( CURRENT == 2 )); then + _describe 'commands' commands + elif (( CURRENT == 3 )); then + case "$words[2]" in + go|editor|ai|rm) + _describe 'branch names' all_options + ;; + new) + _arguments \ + '--from[Base ref]:ref:' \ + '--track[Track mode]:mode:(auto remote local none)' \ + '--no-copy[Skip file copying]' \ + '--no-fetch[Skip git fetch]' \ + '--force[Allow same branch in multiple worktrees]' \ + '--name[Custom folder name suffix]:name:' \ + '--yes[Non-interactive mode]' + ;; + config) + _values 'config action' get set unset + ;; + esac + elif (( CURRENT >= 4 )); then + case "$words[2]" in + rm) + _arguments \ + '--delete-branch[Delete branch]' \ + '--force[Force removal even if dirty]' \ + '--yes[Non-interactive mode]' + ;; + config) + case "$words[3]" in + get|set|unset) + _values 'config key' \ + 'gtr.worktrees.dir' \ + 'gtr.worktrees.prefix' \ + 'gtr.defaultBranch' \ + 'gtr.editor.default' \ + 'gtr.ai.default' \ + 'gtr.copy.include' \ + 'gtr.copy.exclude' \ + 'gtr.hook.postCreate' \ + 'gtr.hook.postRemove' + ;; + esac + ;; + esac + fi +} + +_gtr "$@" + +# Register completion +compdef _gtr gtr