-
Notifications
You must be signed in to change notification settings - Fork 43
feat: add Droid AI adapter and Zsh completion support #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bierlingm
wants to merge
1
commit into
coderabbitai:main
Choose a base branch
from
bierlingm:feature/add-droid-adapter-and-zsh-completion
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 "$@") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify
_describeis the correct Zsh completion function for branches without descriptions.The code uses
_describe 'branch names' all_optionsto suggest branches, but_describeis typically used when the array has "value:description" entries (like the commands array at lines 7-21). Since branch names lack descriptions,_valuesmay be more appropriate or even direct completion via array expansion. Verify this is correct against the Zsh completion API.If correction is needed, replace line 34 with:
🌐 Web query:
💡 Result:
Use the value:description form. _describe expects the first array to contain entries like "completion:description" (or a first array of value:description and a second parallel array of the actual values). Plain arrays without colon are allowed but won’t supply per-item descriptions. [1][2]
Sources:
[1] zshcompsys manual (man page) — description of _describe and the "completion:description" array format.
[2] Arch/Ubuntu zshcompsys man pages — same explanation and examples.
Based on the search results, examples in Zsh completion documentation show
_valuesused with plain arrays as_values 'profiles' $(_netctl_profiles), confirming this is the idiomatic approach for plain arrays without descriptions. The original review's concern is valid—while_describeallows plain arrays, it won't supply per-item descriptions and is semantically designed for "value:description" entries.Use
_valuesinstead of_describefor branch name completion at line 34.This is a code quality improvement. Replace with:
📝 Committable suggestion
🤖 Prompt for AI Agents