Skip to content

Commit 77738c4

Browse files
helizagaNatoBoram
authored andcommitted
fixes discussed in call (#5)
1 parent 6fdc231 commit 77738c4

File tree

8 files changed

+160
-93
lines changed

8 files changed

+160
-93
lines changed

CLAUDE.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Test changes using this comprehensive checklist (from CONTRIBUTING.md):
6464

6565
# Open in editor (if testing adapters)
6666
./bin/gtr config set gtr.editor.default cursor
67-
./bin/gtr open test-feature
67+
./bin/gtr editor test-feature
6868
# Expected: Opens Cursor at worktree path
6969

7070
# Run AI tool (if testing adapters)
@@ -91,7 +91,7 @@ Test changes using this comprehensive checklist (from CONTRIBUTING.md):
9191

9292
# Test shell completions with tab completion
9393
gtr new <TAB>
94-
gtr open <TAB>
94+
gtr editor <TAB>
9595
# Expected: Shows available branches/worktrees
9696

9797
# Test gtr go for main repo and worktrees
@@ -171,7 +171,7 @@ git --version
171171

172172
**Branch Name Mapping**: Branch names are sanitized to valid folder names (slashes and special chars → hyphens). For example, `feature/user-auth` becomes folder `feature-user-auth`.
173173

174-
**Special ID '1'**: The main repository is always accessible via ID `1` in commands (e.g., `gtr go 1`, `gtr open 1`).
174+
**Special ID '1'**: The main repository is always accessible via ID `1` in commands (e.g., `gtr go 1`, `gtr editor 1`).
175175

176176
**Configuration Storage**: All configuration is stored via `git config` (local, global, or system). No custom config files. This makes settings portable and follows git conventions.
177177

@@ -187,7 +187,7 @@ git --version
187187
Understanding how commands are dispatched through the system:
188188

189189
1. **Entry Point** (`bin/gtr:32-79`): Main dispatcher receives command and routes to appropriate handler
190-
2. **Command Handlers** (`bin/gtr`): Each `cmd_*` function handles a specific command (e.g., `cmd_create`, `cmd_open`, `cmd_ai`)
190+
2. **Command Handlers** (`bin/gtr`): Each `cmd_*` function handles a specific command (e.g., `cmd_create`, `cmd_editor`, `cmd_ai`)
191191
3. **Library Functions** (`lib/*.sh`): Command handlers call reusable functions from library modules
192192
4. **Adapters** (`adapters/*`): Dynamically loaded when needed via `load_editor_adapter` or `load_ai_adapter`
193193

@@ -202,11 +202,11 @@ bin/gtr main()
202202
→ run_hooks_in() [lib/hooks.sh]
203203
```
204204

205-
**Example flow for `gtr open my-feature`:**
205+
**Example flow for `gtr editor my-feature`:**
206206

207207
```
208208
bin/gtr main()
209-
cmd_open()
209+
cmd_editor()
210210
→ resolve_target() [lib/core.sh]
211211
→ load_editor_adapter()
212212
→ editor_open() [adapters/editor/*.sh]
@@ -413,7 +413,7 @@ bash -c 'source adapters/editor/cursor.sh && editor_can_open && echo "Available"
413413
bash -c 'source adapters/ai/claude.sh && ai_can_start && echo "Available" || echo "Not found"'
414414

415415
# Debug adapter loading with trace
416-
bash -x ./bin/gtr open test-feature --editor cursor
416+
bash -x ./bin/gtr editor test-feature --editor cursor
417417
# Shows full execution trace including adapter loading
418418
```
419419

README.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ gtr config set gtr.ai.default claude # One-time setup
3838

3939
# Daily workflow
4040
gtr new my-feature # Create worktree
41-
gtr open my-feature # Open in editor
41+
gtr editor my-feature # Open in editor
4242
gtr ai my-feature # Start AI tool
4343
gtr rm my-feature # Remove when done
4444
```
@@ -50,7 +50,7 @@ While `git worktree` is powerful, it's verbose and manual. `gtr` adds quality-of
5050
| Task | With `git worktree` | With `gtr` |
5151
| ----------------- | ------------------------------------------ | ------------------------------------ |
5252
| Create worktree | `git worktree add ../repo-feature feature` | `gtr new feature` |
53-
| Open in editor | `cd ../repo-feature && cursor .` | `gtr open feature` |
53+
| Open in editor | `cd ../repo-feature && cursor .` | `gtr editor feature` |
5454
| Start AI tool | `cd ../repo-feature && aider` | `gtr ai feature` |
5555
| Copy config files | Manual copy/paste | Auto-copy via `gtr.copy.include` |
5656
| Run build steps | Manual `npm install && npm run build` | Auto-run via `gtr.hook.postCreate` |
@@ -83,7 +83,7 @@ gtr config set gtr.ai.default claude
8383

8484
# Daily workflow
8585
gtr new my-feature # Create worktree folder: my-feature
86-
gtr open my-feature # Open in cursor
86+
gtr editor my-feature # Open in cursor
8787
gtr ai my-feature # Start claude
8888

8989
# Navigate to worktree
@@ -175,13 +175,13 @@ gtr new my-feature --name descriptive-variant # Optional: custom name without
175175
- `--name <suffix>`: Custom folder name suffix (optional, required with --force)
176176
- `--yes`: Non-interactive mode
177177

178-
### `gtr open <branch> [--editor <name>]`
178+
### `gtr editor <branch> [--editor <name>]`
179179

180180
Open worktree in editor (uses `gtr.editor.default` or `--editor` flag).
181181

182182
```bash
183-
gtr open my-feature # Uses configured editor
184-
gtr open my-feature --editor vscode # Override with vscode
183+
gtr editor my-feature # Uses configured editor
184+
gtr editor my-feature --editor vscode # Override with vscode
185185
```
186186

187187
### `gtr ai <branch> [--ai <name>] [-- args...]`
@@ -220,7 +220,7 @@ gtr rm my-feature --delete-branch --force # Delete branch and force
220220

221221
List all worktrees. Use `--porcelain` for machine-readable output.
222222

223-
### `gtr config {get|set|unset} <key> [value] [--global]`
223+
### `gtr config {get|set|add|unset} <key> [value] [--global]`
224224

225225
Manage configuration via git config.
226226

@@ -324,13 +324,13 @@ Copy files to new worktrees using glob patterns:
324324

325325
```bash
326326
# Add patterns to copy (multi-valued)
327-
git config --add gtr.copy.include "**/.env.example"
328-
git config --add gtr.copy.include "**/CLAUDE.md"
329-
git config --add gtr.copy.include "*.config.js"
327+
gtr config add gtr.copy.include "**/.env.example"
328+
gtr config add gtr.copy.include "**/CLAUDE.md"
329+
gtr config add gtr.copy.include "*.config.js"
330330

331331
# Exclude patterns (multi-valued)
332-
git config --add gtr.copy.exclude "**/.env"
333-
git config --add gtr.copy.exclude "**/secrets.*"
332+
gtr config add gtr.copy.exclude "**/.env"
333+
gtr config add gtr.copy.exclude "**/secrets.*"
334334
```
335335

336336
**⚠️ Security Note:** Be careful not to copy sensitive files. Use `.env.example` instead of `.env`.
@@ -341,11 +341,11 @@ Run custom commands after worktree operations:
341341

342342
```bash
343343
# Post-create hooks (multi-valued, run in order)
344-
git config --add gtr.hook.postCreate "npm install"
345-
git config --add gtr.hook.postCreate "npm run build"
344+
gtr config add gtr.hook.postCreate "npm install"
345+
gtr config add gtr.hook.postCreate "npm run build"
346346

347347
# Post-remove hooks
348-
git config --add gtr.hook.postRemove "echo 'Cleaned up!'"
348+
gtr config add gtr.hook.postRemove "echo 'Cleaned up!'"
349349
```
350350

351351
**Environment variables available in hooks:**
@@ -358,55 +358,55 @@ git config --add gtr.hook.postRemove "echo 'Cleaned up!'"
358358

359359
```bash
360360
# Node.js (npm)
361-
git config --add gtr.hook.postCreate "npm install"
361+
gtr config add gtr.hook.postCreate "npm install"
362362

363363
# Node.js (pnpm)
364-
git config --add gtr.hook.postCreate "pnpm install"
364+
gtr config add gtr.hook.postCreate "pnpm install"
365365

366366
# Python
367-
git config --add gtr.hook.postCreate "pip install -r requirements.txt"
367+
gtr config add gtr.hook.postCreate "pip install -r requirements.txt"
368368

369369
# Ruby
370-
git config --add gtr.hook.postCreate "bundle install"
370+
gtr config add gtr.hook.postCreate "bundle install"
371371

372372
# Rust
373-
git config --add gtr.hook.postCreate "cargo build"
373+
gtr config add gtr.hook.postCreate "cargo build"
374374
```
375375

376376
## Configuration Examples
377377

378378
### Minimal Setup (Just Basics)
379379

380380
```bash
381-
git config --local gtr.worktrees.prefix "wt-"
382-
git config --local gtr.defaultBranch "main"
381+
gtr config set gtr.worktrees.prefix "wt-"
382+
gtr config set gtr.defaultBranch "main"
383383
```
384384

385385
### Full-Featured Setup (Node.js Project)
386386

387387
```bash
388388
# Worktree settings
389-
git config --local gtr.worktrees.prefix "wt-"
389+
gtr config set gtr.worktrees.prefix "wt-"
390390

391391
# Editor
392-
git config --local gtr.editor.default cursor
392+
gtr config set gtr.editor.default cursor
393393

394394
# Copy environment templates
395-
git config --local --add gtr.copy.include "**/.env.example"
396-
git config --local --add gtr.copy.include "**/.env.development"
397-
git config --local --add gtr.copy.exclude "**/.env.local"
395+
gtr config add gtr.copy.include "**/.env.example"
396+
gtr config add gtr.copy.include "**/.env.development"
397+
gtr config add gtr.copy.exclude "**/.env.local"
398398

399399
# Build hooks
400-
git config --local --add gtr.hook.postCreate "pnpm install"
401-
git config --local --add gtr.hook.postCreate "pnpm run build"
400+
gtr config add gtr.hook.postCreate "pnpm install"
401+
gtr config add gtr.hook.postCreate "pnpm run build"
402402
```
403403

404404
### Global Defaults
405405

406406
```bash
407407
# Set global preferences
408-
git config --global gtr.editor.default cursor
409-
git config --global gtr.ai.default claude
408+
gtr config set gtr.editor.default cursor --global
409+
gtr config set gtr.ai.default claude --global
410410
```
411411

412412
## Advanced Usage
@@ -425,11 +425,11 @@ git config --global gtr.ai.default claude
425425
```bash
426426
# Terminal 1: Work on feature
427427
gtr new feature-a
428-
gtr open feature-a
428+
gtr editor feature-a
429429

430430
# Terminal 2: Review PR
431431
gtr new pr/123
432-
gtr open pr/123
432+
gtr editor pr/123
433433

434434
# Terminal 3: Navigate to main branch (repo root)
435435
cd "$(gtr go 1)" # Special ID '1' = main repo
@@ -448,7 +448,7 @@ gtr list
448448
# auth-feature ~/GitHub/frontend-worktrees/auth-feature
449449
# nav-redesign ~/GitHub/frontend-worktrees/nav-redesign
450450

451-
gtr open auth-feature # Open frontend auth work
451+
gtr editor auth-feature # Open frontend auth work
452452
gtr ai nav-redesign # AI on frontend nav work
453453

454454
# Backend repo (separate worktrees)
@@ -459,12 +459,12 @@ gtr list
459459
# api-auth ~/GitHub/backend-worktrees/api-auth
460460
# websockets ~/GitHub/backend-worktrees/websockets
461461

462-
gtr open api-auth # Open backend auth work
462+
gtr editor api-auth # Open backend auth work
463463
gtr ai websockets # AI on backend websockets
464464

465465
# Switch back to frontend
466466
cd ~/GitHub/frontend
467-
gtr open auth-feature # Opens frontend auth
467+
gtr editor auth-feature # Opens frontend auth
468468
```
469469

470470
**Key point:** Each repository has its own worktrees. Use branch names to identify worktrees.
@@ -477,17 +477,17 @@ Create a `.gtr-setup.sh` in your repo:
477477
#!/bin/sh
478478
# .gtr-setup.sh - Project-specific gtr configuration
479479

480-
git config --local gtr.worktrees.prefix "dev-"
481-
git config --local gtr.editor.default cursor
480+
gtr config set gtr.worktrees.prefix "dev-"
481+
gtr config set gtr.editor.default cursor
482482

483483
# Copy configs
484-
git config --local --add gtr.copy.include ".env.example"
485-
git config --local --add gtr.copy.include "docker-compose.yml"
484+
gtr config add gtr.copy.include ".env.example"
485+
gtr config add gtr.copy.include "docker-compose.yml"
486486

487487
# Setup hooks
488-
git config --local --add gtr.hook.postCreate "docker-compose up -d db"
489-
git config --local --add gtr.hook.postCreate "npm install"
490-
git config --local --add gtr.hook.postCreate "npm run db:migrate"
488+
gtr config add gtr.hook.postCreate "docker-compose up -d db"
489+
gtr config add gtr.hook.postCreate "npm install"
490+
gtr config add gtr.hook.postCreate "npm run db:migrate"
491491
```
492492

493493
Then run: `sh .gtr-setup.sh`
@@ -585,14 +585,14 @@ command -v cursor # or: code, zed
585585
gtr config get gtr.editor.default
586586

587587
# Try opening again
588-
gtr open 2
588+
gtr editor 2
589589
```
590590

591591
### File Copying Issues
592592

593593
```bash
594594
# Check your patterns
595-
git config --get-all gtr.copy.include
595+
gtr config get gtr.copy.include
596596

597597
# Test patterns with find
598598
cd /path/to/repo

0 commit comments

Comments
 (0)