myaidev-method 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/USER_GUIDE.md +389 -8
  2. package/bin/cli.js +161 -70
  3. package/package.json +1 -1
  4. package/src/lib/ascii-banner.js +100 -0
  5. package/src/templates/claude/commands/myai-deploy-dev.md +500 -0
  6. package/src/templates/claude/commands/myai-deploy-prod.md +837 -0
  7. package/src/templates/claude/commands/myai-deploy-staging.md +331 -0
  8. package/src/templates/claude/commands/myai-git-hotfix.md +957 -0
  9. package/src/templates/claude/commands/myai-git-pr.md +200 -0
  10. package/src/templates/claude/commands/myai-git-release.md +806 -0
  11. package/src/templates/claude/commands/myai-git-sync.md +796 -0
  12. package/src/templates/codex/commands/myai-astro-publish.md +51 -0
  13. package/src/templates/codex/commands/myai-configure.md +185 -0
  14. package/src/templates/codex/commands/myai-content-writer.md +73 -0
  15. package/src/templates/codex/commands/myai-coolify-deploy.md +159 -0
  16. package/src/templates/codex/commands/myai-deploy-dev.md +379 -0
  17. package/src/templates/codex/commands/myai-deploy-prod.md +431 -0
  18. package/src/templates/codex/commands/myai-deploy-staging.md +275 -0
  19. package/src/templates/codex/commands/myai-dev-architect.md +69 -0
  20. package/src/templates/codex/commands/myai-dev-code.md +82 -0
  21. package/src/templates/codex/commands/myai-dev-docs.md +83 -0
  22. package/src/templates/codex/commands/myai-dev-review.md +85 -0
  23. package/src/templates/codex/commands/myai-dev-test.md +84 -0
  24. package/src/templates/codex/commands/myai-docusaurus-publish.md +42 -0
  25. package/src/templates/codex/commands/myai-git-hotfix.md +512 -0
  26. package/src/templates/codex/commands/myai-git-pr.md +196 -0
  27. package/src/templates/codex/commands/myai-git-release.md +516 -0
  28. package/src/templates/codex/commands/myai-git-sync.md +517 -0
  29. package/src/templates/codex/commands/myai-mintlify-publish.md +42 -0
  30. package/src/templates/codex/commands/myai-payloadcms-publish.md +42 -0
  31. package/src/templates/codex/commands/myai-sparc-workflow.md +185 -0
  32. package/src/templates/codex/commands/myai-wordpress-admin.md +143 -0
  33. package/src/templates/codex/commands/myai-wordpress-publish.md +66 -0
  34. package/src/templates/gemini/commands/myai-astro-publish.toml +76 -0
  35. package/src/templates/gemini/commands/myai-configure.toml +188 -0
  36. package/src/templates/gemini/commands/myai-content-writer.toml +76 -0
  37. package/src/templates/gemini/commands/myai-coolify-deploy.toml +138 -0
  38. package/src/templates/gemini/commands/myai-deploy-dev.toml +379 -0
  39. package/src/templates/gemini/commands/myai-deploy-prod.toml +438 -0
  40. package/src/templates/gemini/commands/myai-deploy-staging.toml +275 -0
  41. package/src/templates/gemini/commands/myai-dev-architect.toml +64 -0
  42. package/src/templates/gemini/commands/myai-dev-code.toml +75 -0
  43. package/src/templates/gemini/commands/myai-dev-docs.toml +76 -0
  44. package/src/templates/gemini/commands/myai-dev-review.toml +78 -0
  45. package/src/templates/gemini/commands/myai-dev-test.toml +77 -0
  46. package/src/templates/gemini/commands/myai-docusaurus-publish.toml +63 -0
  47. package/src/templates/gemini/commands/myai-git-hotfix.toml +953 -0
  48. package/src/templates/gemini/commands/myai-git-pr.toml +196 -0
  49. package/src/templates/gemini/commands/myai-git-release.toml +802 -0
  50. package/src/templates/gemini/commands/myai-git-sync.toml +792 -0
  51. package/src/templates/gemini/commands/myai-mintlify-publish.toml +67 -0
  52. package/src/templates/gemini/commands/myai-payloadcms-publish.toml +59 -0
  53. package/src/templates/gemini/commands/myai-sparc-workflow.toml +47 -0
  54. package/src/templates/gemini/commands/myai-wordpress-admin.toml +143 -0
  55. package/src/templates/gemini/commands/myai-wordpress-publish.toml +77 -0
@@ -0,0 +1,792 @@
1
+ prompt = """
2
+
3
+ Task: Sync branches and manage git workflow - {{args}}
4
+
5
+ ## Branch Synchronization Workflow
6
+
7
+ ### 1. Branch Status Overview
8
+
9
+ ```bash
10
+ check_branch_status() {
11
+ echo \"🔍 Checking branch status...\"
12
+
13
+ # Current branch
14
+ current_branch=$(git branch --show-current)
15
+ echo \"Current branch: $current_branch\"
16
+
17
+ # Fetch latest from remote
18
+ git fetch --all --prune
19
+
20
+ # List all branches with status
21
+ echo \"\"
22
+ echo \"╔══════════════════════════════════════════════════════════╗\"
23
+ echo \"║ BRANCH STATUS ║\"
24
+ echo \"╚══════════════════════════════════════════════════════════╝\"
25
+
26
+ # Local branches
27
+ echo \"\"
28
+ echo \"📍 Local Branches:\"
29
+ git branch -vv
30
+
31
+ # Remote branches
32
+ echo \"\"
33
+ echo \"☁️ Remote Branches:\"
34
+ git branch -r
35
+
36
+ # Check for branches ahead/behind
37
+ echo \"\"
38
+ echo \"📊 Sync Status:\"
39
+
40
+ for branch in $(git branch --format='%(refname:short)'); do
41
+ if git rev-parse --verify \"origin/$branch\" &>/dev/null; then
42
+ ahead=$(git rev-list --count \"origin/$branch..$branch\" 2>/dev/null || echo \"0\")
43
+ behind=$(git rev-list --count \"$branch..origin/$branch\" 2>/dev/null || echo \"0\")
44
+
45
+ if [ \"$ahead\" -gt 0 ] || [ \"$behind\" -gt 0 ]; then
46
+ echo \" $branch: ↑$ahead ↓$behind\"
47
+ else
48
+ echo \" $branch: ✅ synced\"
49
+ fi
50
+ else
51
+ echo \" $branch: ⚠️ not on remote\"
52
+ fi
53
+ done
54
+
55
+ echo \"\"
56
+ }
57
+
58
+ # Show status
59
+ check_branch_status
60
+ ```
61
+
62
+ ### 2. Sync Main/Master Branch
63
+
64
+ ```bash
65
+ sync_main_branch() {
66
+ echo \"🔄 Syncing main/master branch...\"
67
+
68
+ # Determine main branch name
69
+ if git show-ref --verify --quiet refs/heads/main; then
70
+ main_branch=\"main\"
71
+ elif git show-ref --verify --quiet refs/heads/master; then
72
+ main_branch=\"master\"
73
+ else
74
+ echo \"❌ No main/master branch found\"
75
+ return 1
76
+ fi
77
+
78
+ echo \"Main branch: $main_branch\"
79
+
80
+ # Save current branch
81
+ current_branch=$(git branch --show-current)
82
+
83
+ # Stash changes if any
84
+ if ! git diff-index --quiet HEAD --; then
85
+ echo \"💾 Stashing local changes...\"
86
+ git stash save \"Auto-stash before sync $(date)\"
87
+ stashed=true
88
+ else
89
+ stashed=false
90
+ fi
91
+
92
+ # Switch to main branch
93
+ git checkout \"$main_branch\" || {
94
+ echo \"❌ Failed to checkout $main_branch\"
95
+ return 1
96
+ }
97
+
98
+ # Pull latest changes
99
+ echo \"⬇️ Pulling latest changes...\"
100
+ git pull origin \"$main_branch\" --rebase || {
101
+ echo \"❌ Failed to pull changes\"
102
+ git checkout \"$current_branch\"
103
+ return 1
104
+ }
105
+
106
+ # Switch back to original branch
107
+ if [ \"$current_branch\" != \"$main_branch\" ]; then
108
+ git checkout \"$current_branch\"
109
+ fi
110
+
111
+ # Restore stashed changes
112
+ if [ \"$stashed\" = true ]; then
113
+ echo \"📂 Restoring stashed changes...\"
114
+ git stash pop
115
+ fi
116
+
117
+ echo \"✅ Main branch synced\"
118
+ }
119
+
120
+ # Sync main
121
+ sync_main_branch
122
+ ```
123
+
124
+ ### 3. Sync Development Branch
125
+
126
+ ```bash
127
+ sync_dev_branch() {
128
+ echo \"🔄 Syncing development branch...\"
129
+
130
+ # Determine dev branch name
131
+ if git show-ref --verify --quiet refs/heads/dev; then
132
+ dev_branch=\"dev\"
133
+ elif git show-ref --verify --quiet refs/heads/develop; then
134
+ dev_branch=\"develop\"
135
+ else
136
+ echo \"⚠️ No dev/develop branch found\"
137
+ return 0
138
+ fi
139
+
140
+ echo \"Dev branch: $dev_branch\"
141
+
142
+ # Save current branch
143
+ current_branch=$(git branch --show-current)
144
+
145
+ # Switch to dev branch
146
+ git checkout \"$dev_branch\"
147
+
148
+ # Pull latest changes
149
+ echo \"⬇️ Pulling latest changes...\"
150
+ git pull origin \"$dev_branch\" --rebase || {
151
+ echo \"❌ Failed to pull changes\"
152
+ git checkout \"$current_branch\"
153
+ return 1
154
+ }
155
+
156
+ # Merge main into dev (keep dev updated with main)
157
+ main_branch=$(git show-ref --verify --quiet refs/heads/main && echo \"main\" || echo \"master\")
158
+
159
+ echo \"🔀 Merging $main_branch into $dev_branch...\"
160
+ git merge \"origin/$main_branch\" --no-edit || {
161
+ echo \"⚠️ Merge conflicts detected\"
162
+ echo \"Resolve conflicts and run: git merge --continue\"
163
+ return 1
164
+ }
165
+
166
+ # Push updated dev branch
167
+ echo \"⬆️ Pushing updated dev branch...\"
168
+ git push origin \"$dev_branch\"
169
+
170
+ # Switch back to original branch
171
+ if [ \"$current_branch\" != \"$dev_branch\" ]; then
172
+ git checkout \"$current_branch\"
173
+ fi
174
+
175
+ echo \"✅ Dev branch synced\"
176
+ }
177
+
178
+ # Sync dev
179
+ sync_dev_branch
180
+ ```
181
+
182
+ ### 4. Sync Staging Branch
183
+
184
+ ```bash
185
+ sync_staging_branch() {
186
+ echo \"🔄 Syncing staging branch...\"
187
+
188
+ if ! git show-ref --verify --quiet refs/heads/staging; then
189
+ echo \"⚠️ No staging branch found\"
190
+ return 0
191
+ fi
192
+
193
+ # Save current branch
194
+ current_branch=$(git branch --show-current)
195
+
196
+ # Switch to staging
197
+ git checkout staging
198
+
199
+ # Pull latest changes
200
+ echo \"⬇️ Pulling latest changes...\"
201
+ git pull origin staging --rebase || {
202
+ echo \"❌ Failed to pull changes\"
203
+ git checkout \"$current_branch\"
204
+ return 1
205
+ }
206
+
207
+ # Merge dev into staging
208
+ dev_branch=$(git show-ref --verify --quiet refs/heads/dev && echo \"dev\" || echo \"develop\")
209
+
210
+ if git show-ref --verify --quiet \"refs/heads/$dev_branch\"; then
211
+ echo \"🔀 Merging $dev_branch into staging...\"
212
+ git merge \"origin/$dev_branch\" --no-edit || {
213
+ echo \"⚠️ Merge conflicts detected\"
214
+ return 1
215
+ }
216
+
217
+ # Push updated staging branch
218
+ echo \"⬆️ Pushing updated staging branch...\"
219
+ git push origin staging
220
+ fi
221
+
222
+ # Switch back to original branch
223
+ if [ \"$current_branch\" != \"staging\" ]; then
224
+ git checkout \"$current_branch\"
225
+ fi
226
+
227
+ echo \"✅ Staging branch synced\"
228
+ }
229
+
230
+ # Sync staging
231
+ sync_staging_branch
232
+ ```
233
+
234
+ ### 5. Merge Main into Feature Branch
235
+
236
+ ```bash
237
+ merge_main_into_feature() {
238
+ local feature_branch=${1:-$(git branch --show-current)}
239
+
240
+ echo \"🔀 Merging main into feature branch: $feature_branch...\"
241
+
242
+ # Ensure we're on the feature branch
243
+ if [ \"$(git branch --show-current)\" != \"$feature_branch\" ]; then
244
+ git checkout \"$feature_branch\" || {
245
+ echo \"❌ Failed to checkout $feature_branch\"
246
+ return 1
247
+ }
248
+ fi
249
+
250
+ # Determine main branch
251
+ main_branch=$(git show-ref --verify --quiet refs/heads/main && echo \"main\" || echo \"master\")
252
+
253
+ # Fetch latest
254
+ git fetch origin \"$main_branch\"
255
+
256
+ # Check if feature branch is behind main
257
+ behind=$(git rev-list --count \"$feature_branch..origin/$main_branch\")
258
+
259
+ if [ \"$behind\" -eq 0 ]; then
260
+ echo \"✅ Feature branch is up to date with $main_branch\"
261
+ return 0
262
+ fi
263
+
264
+ echo \"📊 Feature branch is $behind commits behind $main_branch\"
265
+
266
+ # Stash changes if any
267
+ if ! git diff-index --quiet HEAD --; then
268
+ echo \"💾 Stashing local changes...\"
269
+ git stash save \"Auto-stash before merge $(date)\"
270
+ stashed=true
271
+ else
272
+ stashed=false
273
+ fi
274
+
275
+ # Merge main into feature
276
+ echo \"🔀 Merging $main_branch...\"
277
+ git merge \"origin/$main_branch\" --no-edit || {
278
+ echo \"⚠️ Merge conflicts detected\"
279
+ echo \"\"
280
+ echo \"Conflicted files:\"
281
+ git diff --name-only --diff-filter=U
282
+ echo \"\"
283
+ echo \"Resolve conflicts then run:\"
284
+ echo \" git add <resolved-files>\"
285
+ echo \" git merge --continue\"
286
+
287
+ if [ \"$stashed\" = true ]; then
288
+ echo \" git stash pop\"
289
+ fi
290
+
291
+ return 1
292
+ }
293
+
294
+ # Restore stashed changes
295
+ if [ \"$stashed\" = true ]; then
296
+ echo \"📂 Restoring stashed changes...\"
297
+ git stash pop
298
+ fi
299
+
300
+ # Push updated feature branch
301
+ read -p \"Push updated feature branch? (yes/no): \" push_confirm
302
+
303
+ if [ \"$push_confirm\" == \"yes\" ]; then
304
+ git push origin \"$feature_branch\"
305
+ echo \"✅ Feature branch pushed\"
306
+ fi
307
+
308
+ echo \"✅ Main merged into feature branch\"
309
+ }
310
+
311
+ # Merge main into current branch
312
+ merge_main_into_feature
313
+ ```
314
+
315
+ ### 6. Sync All Branches
316
+
317
+ ```bash
318
+ sync_all_branches() {
319
+ echo \"🔄 Syncing all branches...\"
320
+
321
+ # Save current branch
322
+ current_branch=$(git branch --show-current)
323
+
324
+ # Fetch all
325
+ git fetch --all --prune
326
+
327
+ # Define branch hierarchy
328
+ main_branch=$(git show-ref --verify --quiet refs/heads/main && echo \"main\" || echo \"master\")
329
+ dev_branch=$(git show-ref --verify --quiet refs/heads/dev && echo \"dev\" || echo \"develop\")
330
+
331
+ # Sync main
332
+ echo \"\"
333
+ echo \"═══════════════════════════════════════\"
334
+ echo \"Syncing $main_branch...\"
335
+ echo \"═══════════════════════════════════════\"
336
+ git checkout \"$main_branch\"
337
+ git pull origin \"$main_branch\" --rebase
338
+
339
+ # Sync dev
340
+ if git show-ref --verify --quiet \"refs/heads/$dev_branch\"; then
341
+ echo \"\"
342
+ echo \"═══════════════════════════════════════\"
343
+ echo \"Syncing $dev_branch...\"
344
+ echo \"═══════════════════════════════════════\"
345
+ git checkout \"$dev_branch\"
346
+ git pull origin \"$dev_branch\" --rebase
347
+ git merge \"origin/$main_branch\" --no-edit
348
+ git push origin \"$dev_branch\"
349
+ fi
350
+
351
+ # Sync staging
352
+ if git show-ref --verify --quiet refs/heads/staging; then
353
+ echo \"\"
354
+ echo \"═══════════════════════════════════════\"
355
+ echo \"Syncing staging...\"
356
+ echo \"═══════════════════════════════════════\"
357
+ git checkout staging
358
+ git pull origin staging --rebase
359
+ if git show-ref --verify --quiet \"refs/heads/$dev_branch\"; then
360
+ git merge \"origin/$dev_branch\" --no-edit
361
+ else
362
+ git merge \"origin/$main_branch\" --no-edit
363
+ fi
364
+ git push origin staging
365
+ fi
366
+
367
+ # Return to original branch
368
+ git checkout \"$current_branch\"
369
+
370
+ echo \"\"
371
+ echo \"✅ All branches synced\"
372
+ }
373
+
374
+ # Uncomment to sync all branches
375
+ # sync_all_branches
376
+ ```
377
+
378
+ ### 7. Clean Up Merged Branches
379
+
380
+ ```bash
381
+ cleanup_merged_branches() {
382
+ echo \"🧹 Cleaning up merged branches...\"
383
+
384
+ # Determine main branch
385
+ main_branch=$(git show-ref --verify --quiet refs/heads/main && echo \"main\" || echo \"master\")
386
+
387
+ # Fetch and prune
388
+ git fetch --all --prune
389
+
390
+ # Find merged branches
391
+ echo \"🔍 Finding merged branches...\"
392
+
393
+ merged_branches=$(git branch --merged \"$main_branch\" | \\
394
+ grep -v \"^\\*\" | \\
395
+ grep -v \"$main_branch\" | \\
396
+ grep -v \"develop\" | \\
397
+ grep -v \"dev\" | \\
398
+ grep -v \"staging\" | \\
399
+ grep -v \"production\")
400
+
401
+ if [ -z \"$merged_branches\" ]; then
402
+ echo \"✅ No merged branches to clean up\"
403
+ return 0
404
+ fi
405
+
406
+ echo \"Branches merged into $main_branch:\"
407
+ echo \"$merged_branches\"
408
+ echo \"\"
409
+
410
+ read -p \"Delete these local branches? (yes/no): \" delete_confirm
411
+
412
+ if [ \"$delete_confirm\" == \"yes\" ]; then
413
+ echo \"$merged_branches\" | xargs git branch -d
414
+ echo \"✅ Local branches deleted\"
415
+ fi
416
+
417
+ # Check remote branches
418
+ echo \"\"
419
+ echo \"🔍 Checking remote merged branches...\"
420
+
421
+ remote_merged=$(git branch -r --merged \"$main_branch\" | \\
422
+ grep -v \"HEAD\" | \\
423
+ grep -v \"$main_branch\" | \\
424
+ grep -v \"develop\" | \\
425
+ grep -v \"dev\" | \\
426
+ grep -v \"staging\" | \\
427
+ grep -v \"production\" | \\
428
+ sed 's/origin\\///')
429
+
430
+ if [ -z \"$remote_merged\" ]; then
431
+ echo \"✅ No remote merged branches\"
432
+ return 0
433
+ fi
434
+
435
+ echo \"Remote branches merged into $main_branch:\"
436
+ echo \"$remote_merged\"
437
+ echo \"\"
438
+
439
+ read -p \"Delete these remote branches? (yes/no): \" delete_remote
440
+
441
+ if [ \"$delete_remote\" == \"yes\" ]; then
442
+ echo \"$remote_merged\" | xargs -I {} git push origin --delete {}
443
+ echo \"✅ Remote branches deleted\"
444
+ fi
445
+
446
+ echo \"✅ Branch cleanup complete\"
447
+ }
448
+
449
+ # Cleanup merged branches
450
+ cleanup_merged_branches
451
+ ```
452
+
453
+ ### 8. Handle Merge Conflicts
454
+
455
+ ```bash
456
+ handle_merge_conflicts() {
457
+ echo \"🔧 Merge conflict resolution helper...\"
458
+
459
+ # Check if in merge state
460
+ if [ ! -f \".git/MERGE_HEAD\" ]; then
461
+ echo \"✅ No active merge conflicts\"
462
+ return 0
463
+ fi
464
+
465
+ echo \"⚠️ Active merge detected\"
466
+
467
+ # Show conflicted files
468
+ echo \"\"
469
+ echo \"📋 Conflicted files:\"
470
+ git diff --name-only --diff-filter=U
471
+
472
+ echo \"\"
473
+ echo \"Conflict resolution options:\"
474
+ echo \" 1. Use ours (keep current branch changes)\"
475
+ echo \" 2. Use theirs (accept incoming changes)\"
476
+ echo \" 3. Manual resolution\"
477
+ echo \" 4. Abort merge\"
478
+ echo \"\"
479
+
480
+ read -p \"Choose option (1-4): \" option
481
+
482
+ case $option in
483
+ 1)
484
+ echo \"Accepting current branch changes...\"
485
+ git diff --name-only --diff-filter=U | xargs git checkout --ours
486
+ git add -A
487
+ git merge --continue
488
+ ;;
489
+ 2)
490
+ echo \"Accepting incoming changes...\"
491
+ git diff --name-only --diff-filter=U | xargs git checkout --theirs
492
+ git add -A
493
+ git merge --continue
494
+ ;;
495
+ 3)
496
+ echo \"Opening merge tool...\"
497
+ git mergetool
498
+ ;;
499
+ 4)
500
+ echo \"Aborting merge...\"
501
+ git merge --abort
502
+ echo \"✅ Merge aborted\"
503
+ ;;
504
+ *)
505
+ echo \"Invalid option\"
506
+ ;;
507
+ esac
508
+ }
509
+
510
+ # Handle conflicts if present
511
+ handle_merge_conflicts
512
+ ```
513
+
514
+ ### 9. Branch Comparison
515
+
516
+ ```bash
517
+ compare_branches() {
518
+ local branch1=${1:-main}
519
+ local branch2=${2:-$(git branch --show-current)}
520
+
521
+ echo \"🔍 Comparing branches: $branch1 vs $branch2\"
522
+
523
+ # Fetch latest
524
+ git fetch origin
525
+
526
+ # Commits in branch2 not in branch1
527
+ echo \"\"
528
+ echo \"📊 Commits in $branch2 not in $branch1:\"
529
+ ahead_count=$(git rev-list --count \"$branch1..$branch2\")
530
+ echo \"Total: $ahead_count commits\"
531
+ if [ \"$ahead_count\" -gt 0 ]; then
532
+ git log --oneline \"$branch1..$branch2\"
533
+ fi
534
+
535
+ # Commits in branch1 not in branch2
536
+ echo \"\"
537
+ echo \"📊 Commits in $branch1 not in $branch2:\"
538
+ behind_count=$(git rev-list --count \"$branch2..$branch1\")
539
+ echo \"Total: $behind_count commits\"
540
+ if [ \"$behind_count\" -gt 0 ]; then
541
+ git log --oneline \"$branch2..$branch1\"
542
+ fi
543
+
544
+ # File differences
545
+ echo \"\"
546
+ echo \"📁 File differences:\"
547
+ git diff --stat \"$branch1..$branch2\"
548
+
549
+ # Summary
550
+ echo \"\"
551
+ echo \"═══════════════════════════════════════\"
552
+ echo \"SUMMARY\"
553
+ echo \"═══════════════════════════════════════\"
554
+ echo \"$branch2 is:\"
555
+ echo \" ↑ $ahead_count commits ahead\"
556
+ echo \" ↓ $behind_count commits behind\"
557
+ echo \" of $branch1\"
558
+ }
559
+
560
+ # Compare current branch with main
561
+ # compare_branches \"main\" \"$(git branch --show-current)\"
562
+ ```
563
+
564
+ ### 10. Pull Request Ready Check
565
+
566
+ ```bash
567
+ pr_ready_check() {
568
+ local feature_branch=${1:-$(git branch --show-current)}
569
+
570
+ echo \"✅ PR Ready Check: $feature_branch\"
571
+
572
+ # Determine main branch
573
+ main_branch=$(git show-ref --verify --quiet refs/heads/main && echo \"main\" || echo \"master\")
574
+
575
+ # Fetch latest
576
+ git fetch origin
577
+
578
+ # Check 1: Branch is pushed
579
+ if ! git rev-parse --verify \"origin/$feature_branch\" &>/dev/null; then
580
+ echo \"❌ Branch not pushed to remote\"
581
+ echo \" Run: git push origin $feature_branch\"
582
+ return 1
583
+ fi
584
+
585
+ # Check 2: No uncommitted changes
586
+ if ! git diff-index --quiet HEAD --; then
587
+ echo \"❌ Uncommitted changes detected\"
588
+ git status --short
589
+ return 1
590
+ fi
591
+
592
+ # Check 3: Up to date with main
593
+ behind=$(git rev-list --count \"$feature_branch..origin/$main_branch\")
594
+ if [ \"$behind\" -gt 0 ]; then
595
+ echo \"⚠️ Branch is $behind commits behind $main_branch\"
596
+ echo \" Consider merging main: /myai-git-sync merge-main\"
597
+ fi
598
+
599
+ # Check 4: Conflicts with main
600
+ if ! git merge-tree \"$(git merge-base $feature_branch origin/$main_branch)\" \"$feature_branch\" \"origin/$main_branch\" | grep -q \"^-\"; then
601
+ echo \"✅ No conflicts with $main_branch\"
602
+ else
603
+ echo \"⚠️ May have conflicts with $main_branch\"
604
+ fi
605
+
606
+ # Check 5: Tests pass
607
+ echo \"🧪 Running tests...\"
608
+ if npm test &>/dev/null; then
609
+ echo \"✅ Tests passing\"
610
+ else
611
+ echo \"❌ Tests failing\"
612
+ return 1
613
+ fi
614
+
615
+ # Check 6: Linting
616
+ if command -v npm &>/dev/null && grep -q \"\\\"lint\\\"\" package.json 2>/dev/null; then
617
+ if npm run lint &>/dev/null; then
618
+ echo \"✅ Linting passing\"
619
+ else
620
+ echo \"⚠️ Linting issues detected\"
621
+ fi
622
+ fi
623
+
624
+ # Summary
625
+ echo \"\"
626
+ echo \"═══════════════════════════════════════\"
627
+ echo \"✅ Ready to create Pull Request!\"
628
+ echo \"═══════════════════════════════════════\"
629
+
630
+ # Generate PR creation command
631
+ if command -v gh &>/dev/null; then
632
+ echo \"\"
633
+ echo \"Create PR with:\"
634
+ echo \" gh pr create --base $main_branch --head $feature_branch\"
635
+ fi
636
+ }
637
+
638
+ # Check if ready for PR
639
+ pr_ready_check
640
+ ```
641
+
642
+ ### 11. Sync Notification
643
+
644
+ ```bash
645
+ send_sync_notification() {
646
+ local sync_summary=$1
647
+
648
+ # Slack notification
649
+ if [ -n \"$SLACK_WEBHOOK_URL\" ]; then
650
+ curl -X POST \"$SLACK_WEBHOOK_URL\" \\
651
+ -H 'Content-Type: application/json' \\
652
+ -d \"{
653
+ \\\"text\\\": \\\"🔄 Branch Sync Complete\\\",
654
+ \\\"blocks\\\": [
655
+ {
656
+ \\\"type\\\": \\\"section\\\",
657
+ \\\"text\\\": {
658
+ \\\"type\\\": \\\"mrkdwn\\\",
659
+ \\\"text\\\": \\\"*Branch Synchronization*\\n$sync_summary\\\"
660
+ }
661
+ }
662
+ ]
663
+ }\"
664
+ fi
665
+
666
+ # Discord notification
667
+ if [ -n \"$DISCORD_WEBHOOK_URL\" ]; then
668
+ curl -X POST \"$DISCORD_WEBHOOK_URL\" \\
669
+ -H 'Content-Type: application/json' \\
670
+ -d \"{
671
+ \\\"content\\\": \\\"🔄 **Branch Sync Complete**\\\",
672
+ \\\"embeds\\\": [{
673
+ \\\"description\\\": \\\"$sync_summary\\\",
674
+ \\\"color\\\": 3447003
675
+ }]
676
+ }\"
677
+ fi
678
+ }
679
+ ```
680
+
681
+ ## Complete Sync Script
682
+
683
+ ```bash
684
+ #!/bin/bash
685
+ set -e
686
+
687
+ echo \"🔄 Git Branch Synchronization\"
688
+ echo \"═══════════════════════════════════════\"
689
+
690
+ # Parse arguments
691
+ action=${1:-status}
692
+
693
+ case $action in
694
+ status)
695
+ check_branch_status
696
+ ;;
697
+
698
+ main)
699
+ sync_main_branch
700
+ ;;
701
+
702
+ dev)
703
+ sync_dev_branch
704
+ ;;
705
+
706
+ staging)
707
+ sync_staging_branch
708
+ ;;
709
+
710
+ all)
711
+ sync_all_branches
712
+ ;;
713
+
714
+ merge-main)
715
+ merge_main_into_feature
716
+ ;;
717
+
718
+ cleanup)
719
+ cleanup_merged_branches
720
+ ;;
721
+
722
+ compare)
723
+ compare_branches \"$2\" \"$3\"
724
+ ;;
725
+
726
+ pr-check)
727
+ pr_ready_check \"$2\"
728
+ ;;
729
+
730
+ conflicts)
731
+ handle_merge_conflicts
732
+ ;;
733
+
734
+ *)
735
+ echo \"Usage: /myai-git-sync [command]\"
736
+ echo \"\"
737
+ echo \"Commands:\"
738
+ echo \" status - Show branch status overview\"
739
+ echo \" main - Sync main/master branch\"
740
+ echo \" dev - Sync dev/develop branch\"
741
+ echo \" staging - Sync staging branch\"
742
+ echo \" all - Sync all branches\"
743
+ echo \" merge-main - Merge main into current feature branch\"
744
+ echo \" cleanup - Clean up merged branches\"
745
+ echo \" compare - Compare two branches\"
746
+ echo \" pr-check - Check if ready for pull request\"
747
+ echo \" conflicts - Handle merge conflicts\"
748
+ ;;
749
+ esac
750
+
751
+ echo \"\"
752
+ echo \"✅ Sync operation complete\"
753
+ ```
754
+
755
+ ## Quick Commands
756
+
757
+ ```bash
758
+ # Check status
759
+ /myai-git-sync status
760
+
761
+ # Sync main branch
762
+ /myai-git-sync main
763
+
764
+ # Sync all branches
765
+ /myai-git-sync all
766
+
767
+ # Merge main into feature
768
+ /myai-git-sync merge-main
769
+
770
+ # Clean up merged branches
771
+ /myai-git-sync cleanup
772
+
773
+ # Check PR readiness
774
+ /myai-git-sync pr-check
775
+ ```
776
+
777
+ ## Environment Configuration
778
+
779
+ ```bash
780
+ # Notifications (optional)
781
+ SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK
782
+ DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK
783
+
784
+ # Branch names (defaults)
785
+ MAIN_BRANCH=main
786
+ DEV_BRANCH=dev
787
+ STAGING_BRANCH=staging
788
+ ```
789
+
790
+ Execute branch synchronization and management operations efficiently.
791
+
792
+ """