-
Notifications
You must be signed in to change notification settings - Fork 82
modularize bin/gtr into libraries and add BATS test suite #119
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
Merged
helizaga
merged 19 commits into
main
from
refactor/reduce-adapter-and-config-duplication
Feb 12, 2026
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8ab2d56
refactor: standardize AI and editor adapter initialization
helizaga 1aa5b20
refactor: streamline editor adapter scripts with terminal definition
helizaga 9cd81a4
refactor: simplify get_current_branch function logic
helizaga 06c2301
feat: add CI workflow for linting and testing
helizaga 5368d32
fix: address CI failures and review feedback
helizaga 25ede69
refactor: improve error handling in copy_directories function
helizaga 98858e3
refactor: enhance current_branch function for better detection
helizaga e56424d
refactor: enhance adapter management and command structure
helizaga 194212b
refactor: enhance command context handling with shellcheck directives
helizaga 289124b
refactor: enhance testing documentation and command help
helizaga 41c1488
refactor: enhance argument parsing and command completion
helizaga 8a8d7be
fix: use prefix variable in doctor to resolve ShellCheck SC2034
helizaga 847965e
refactor: enhance adapter and configuration management
helizaga 2fcf302
fix: improve error handling in launch and command scripts
helizaga 1a4b73a
refactor: remove unused functions and improve command clarity
helizaga e512a10
refactor: simplify worktree management by removing force flag handling
helizaga 7fdcadf
refactor: update shebang and improve pattern matching in scripts
helizaga 4e3f724
refactor: enhance testing and command structure
helizaga c05ca37
fix: improve directory handling and test execution in clean command
helizaga 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,33 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| shellcheck: | ||
| name: ShellCheck | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install ShellCheck | ||
| run: sudo apt-get install -y shellcheck | ||
|
|
||
| - name: Run ShellCheck | ||
| run: | | ||
| shellcheck bin/gtr bin/git-gtr lib/*.sh adapters/editor/*.sh adapters/ai/*.sh | ||
|
|
||
| test: | ||
| name: Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install BATS | ||
| run: sudo apt-get install -y bats | ||
|
|
||
| - name: Run tests | ||
| run: bats tests/ | ||
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 |
|---|---|---|
| @@ -1,28 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # Aider AI coding assistant adapter | ||
|
|
||
| # Check if Aider is available | ||
| ai_can_start() { | ||
| command -v aider >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Start Aider in a directory | ||
| # Usage: ai_start path [args...] | ||
| ai_start() { | ||
| local path="$1" | ||
| shift | ||
|
|
||
| if ! ai_can_start; then | ||
| log_error "Aider not found. Install with: pip install aider-chat" | ||
| log_info "See https://aider.chat for more information" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$path" ]; then | ||
| log_error "Directory not found: $path" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Change to the directory and run aider with any additional arguments | ||
| (cd "$path" && aider "$@") | ||
| } | ||
| _AI_CMD="aider" | ||
| _AI_ERR_MSG="Aider not found. Install with: pip install aider-chat" | ||
| _AI_INFO_LINES=("See https://aider.chat for more information") | ||
| _ai_define_standard |
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 |
|---|---|---|
| @@ -1,29 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # Auggie CLI AI adapter | ||
|
|
||
| # Check if Auggie is available | ||
| ai_can_start() { | ||
| command -v auggie >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Start Auggie in a directory | ||
| # Usage: ai_start path [args...] | ||
| ai_start() { | ||
| local path="$1" | ||
| shift | ||
|
|
||
| if ! ai_can_start; then | ||
| log_error "Auggie CLI not found. Install with: npm install -g @augmentcode/auggie" | ||
| log_info "See https://www.augmentcode.com/product/CLI for more information" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$path" ]; then | ||
| log_error "Directory not found: $path" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Change to the directory and run auggie with any additional arguments | ||
| (cd "$path" && auggie "$@") | ||
| } | ||
|
|
||
| _AI_CMD="auggie" | ||
| _AI_ERR_MSG="Auggie CLI not found. Install with: npm install -g @augmentcode/auggie" | ||
| _AI_INFO_LINES=("See https://www.augmentcode.com/product/CLI for more information") | ||
| _ai_define_standard |
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 |
|---|---|---|
| @@ -1,29 +1,10 @@ | ||
| #!/usr/bin/env bash | ||
| # OpenAI Codex CLI adapter | ||
|
|
||
| # Check if Codex is available | ||
| ai_can_start() { | ||
| command -v codex >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Start Codex in a directory | ||
| # Usage: ai_start path [args...] | ||
| ai_start() { | ||
| local path="$1" | ||
| shift | ||
|
|
||
| if ! ai_can_start; then | ||
| log_error "Codex CLI not found. Install with: npm install -g @openai/codex" | ||
| log_info "Or: brew install codex" | ||
| log_info "See https://github.com/openai/codex for more info" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$path" ]; then | ||
| log_error "Directory not found: $path" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Change to the directory and run codex with any additional arguments | ||
| (cd "$path" && codex "$@") | ||
| } | ||
| _AI_CMD="codex" | ||
| _AI_ERR_MSG="Codex CLI not found. Install with: npm install -g @openai/codex" | ||
| _AI_INFO_LINES=( | ||
| "Or: brew install codex" | ||
| "See https://github.com/openai/codex for more info" | ||
| ) | ||
| _ai_define_standard |
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 |
|---|---|---|
| @@ -1,28 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # Continue CLI adapter | ||
|
|
||
| # Check if Continue is available | ||
| ai_can_start() { | ||
| command -v cn >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Start Continue in a directory | ||
| # Usage: ai_start path [args...] | ||
| ai_start() { | ||
| local path="$1" | ||
| shift | ||
|
|
||
| if ! ai_can_start; then | ||
| log_error "Continue CLI not found. Install from https://continue.dev" | ||
| log_info "See https://docs.continue.dev/cli/install for installation" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$path" ]; then | ||
| log_error "Directory not found: $path" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Change to the directory and run cn with any additional arguments | ||
| (cd "$path" && cn "$@") | ||
| } | ||
| _AI_CMD="cn" | ||
| _AI_ERR_MSG="Continue CLI not found. Install from https://continue.dev" | ||
| _AI_INFO_LINES=("See https://docs.continue.dev/cli/install for installation") | ||
| _ai_define_standard |
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 |
|---|---|---|
| @@ -1,30 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
| # GitHub Copilot CLI adapter | ||
|
|
||
| # Check if GitHub Copilot CLI is available | ||
| ai_can_start() { | ||
| command -v copilot >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Start GitHub Copilot CLI in a directory | ||
| # Usage: ai_start path [args...] | ||
| ai_start() { | ||
| local path="$1" | ||
| shift | ||
|
|
||
| if ! ai_can_start; then | ||
| log_error "GitHub Copilot CLI not found." | ||
| log_info "Install with: npm install -g @github/copilot" | ||
| log_info "Or: brew install copilot-cli" | ||
| log_info "See https://github.com/github/copilot-cli for more information" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$path" ]; then | ||
| log_error "Directory not found: $path" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Change to the directory and run copilot with any additional arguments | ||
| (cd "$path" && copilot "$@") | ||
| } | ||
| _AI_CMD="copilot" | ||
| _AI_ERR_MSG="GitHub Copilot CLI not found." | ||
| _AI_INFO_LINES=( | ||
| "Install with: npm install -g @github/copilot" | ||
| "Or: brew install copilot-cli" | ||
| "See https://github.com/github/copilot-cli for more information" | ||
| ) | ||
| _ai_define_standard |
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 |
|---|---|---|
| @@ -1,29 +1,10 @@ | ||
| #!/usr/bin/env bash | ||
| # Gemini CLI adapter | ||
|
|
||
| # Check if Gemini is available | ||
| ai_can_start() { | ||
| command -v gemini >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Start Gemini in a directory | ||
| # Usage: ai_start path [args...] | ||
| ai_start() { | ||
| local path="$1" | ||
| shift | ||
|
|
||
| if ! ai_can_start; then | ||
| log_error "Gemini CLI not found. Install with: npm install -g @google/gemini-cli" | ||
| log_info "Or: brew install gemini-cli" | ||
| log_info "See https://github.com/google-gemini/gemini-cli for more info" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$path" ]; then | ||
| log_error "Directory not found: $path" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Change to the directory and run gemini with any additional arguments | ||
| (cd "$path" && gemini "$@") | ||
| } | ||
| _AI_CMD="gemini" | ||
| _AI_ERR_MSG="Gemini CLI not found. Install with: npm install -g @google/gemini-cli" | ||
| _AI_INFO_LINES=( | ||
| "Or: brew install gemini-cli" | ||
| "See https://github.com/google-gemini/gemini-cli for more info" | ||
| ) | ||
| _ai_define_standard |
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 |
|---|---|---|
| @@ -1,29 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # OpenCode adapter | ||
|
|
||
| # Check if OpenCode is available | ||
| ai_can_start() { | ||
| command -v opencode >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Start OpenCode in a directory | ||
| # Usage: ai_start path [args...] | ||
| ai_start() { | ||
| local path="$1" | ||
| shift | ||
|
|
||
| if ! ai_can_start; then | ||
| log_error "OpenCode not found. Install from https://opencode.ai" | ||
| log_info "Make sure the 'opencode' CLI is available in your PATH" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$path" ]; then | ||
| log_error "Directory not found: $path" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Change to the directory and run opencode with any additional arguments | ||
| (cd "$path" && opencode "$@") | ||
| } | ||
|
|
||
| _AI_CMD="opencode" | ||
| _AI_ERR_MSG="OpenCode not found. Install from https://opencode.ai" | ||
| _AI_INFO_LINES=("Make sure the 'opencode' CLI is available in your PATH") | ||
| _ai_define_standard |
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 |
|---|---|---|
| @@ -1,20 +1,6 @@ | ||
| #!/usr/bin/env bash | ||
| # Atom editor adapter | ||
|
|
||
| # Check if Atom is available | ||
| editor_can_open() { | ||
| command -v atom >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Open a directory in Atom | ||
| # Usage: editor_open path | ||
| editor_open() { | ||
| local path="$1" | ||
|
|
||
| if ! editor_can_open; then | ||
| log_error "Atom not found. Install from https://atom.io" | ||
| return 1 | ||
| fi | ||
|
|
||
| atom "$path" | ||
| } | ||
| _EDITOR_CMD="atom" | ||
| _EDITOR_ERR_MSG="Atom not found. Install from https://atom.io" | ||
| _editor_define_standard |
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 |
|---|---|---|
| @@ -1,26 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # Cursor editor adapter | ||
|
|
||
| # Check if Cursor is available | ||
| editor_can_open() { | ||
| command -v cursor >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Open a directory or workspace file in Cursor | ||
| # Usage: editor_open path [workspace_file] | ||
| editor_open() { | ||
| local path="$1" | ||
| local workspace="${2:-}" | ||
|
|
||
| if ! editor_can_open; then | ||
| log_error "Cursor not found. Install from https://cursor.com or enable the shell command." | ||
| return 1 | ||
| fi | ||
|
|
||
| # Open workspace file if provided, otherwise open directory | ||
| if [ -n "$workspace" ] && [ -f "$workspace" ]; then | ||
| cursor "$workspace" | ||
| else | ||
| cursor "$path" | ||
| fi | ||
| } | ||
| _EDITOR_CMD="cursor" | ||
| _EDITOR_ERR_MSG="Cursor not found. Install from https://cursor.com or enable the shell command." | ||
| _EDITOR_WORKSPACE=1 | ||
| _editor_define_standard |
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 |
|---|---|---|
| @@ -1,21 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # Emacs editor adapter | ||
|
|
||
| # Check if Emacs is available | ||
| editor_can_open() { | ||
| command -v emacs >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Open a directory in Emacs | ||
| # Usage: editor_open path | ||
| editor_open() { | ||
| local path="$1" | ||
|
|
||
| if ! editor_can_open; then | ||
| log_error "Emacs not found. Install from https://www.gnu.org/software/emacs/" | ||
| return 1 | ||
| fi | ||
|
|
||
| # Open emacs with the directory | ||
| emacs "$path" & | ||
| } | ||
| _EDITOR_CMD="emacs" | ||
| _EDITOR_ERR_MSG="Emacs not found. Install from https://www.gnu.org/software/emacs/" | ||
| _EDITOR_BACKGROUND=1 | ||
| _editor_define_terminal |
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 |
|---|---|---|
| @@ -1,20 +1,6 @@ | ||
| #!/usr/bin/env bash | ||
| # IntelliJ IDEA editor adapter | ||
|
|
||
| # Check if IntelliJ IDEA is available | ||
| editor_can_open() { | ||
| command -v idea >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Open a directory in IntelliJ IDEA | ||
| # Usage: editor_open path | ||
| editor_open() { | ||
| local path="$1" | ||
|
|
||
| if ! editor_can_open; then | ||
| log_error "IntelliJ IDEA 'idea' command not found. Enable shell launcher in Tools > Create Command-line Launcher" | ||
| return 1 | ||
| fi | ||
|
|
||
| idea "$path" | ||
| } | ||
| _EDITOR_CMD="idea" | ||
| _EDITOR_ERR_MSG="IntelliJ IDEA 'idea' command not found. Enable shell launcher in Tools > Create Command-line Launcher" | ||
| _editor_define_standard |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.