@nemo-cli/git 0.1.3 → 0.1.5

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.
package/README.md CHANGED
@@ -19,6 +19,8 @@ pnpm add @nemo-cli/git --global
19
19
  - **Conventional Commits**: Interactive commit wizard with type/scope selection from your commitlint config
20
20
  - **Smart Branch Management**: Advanced branch operations with merge status and time filtering
21
21
  - **Ticket Auto-Detection**: Automatically extracts ticket numbers from branch names for commit messages
22
+ - **Interactive Commit Navigator**: Enhanced `ng blame` for browsing file history with full diff support
23
+ - **Visual History Viewer**: Beautiful `ng hist` command with interactive graph display and keyboard navigation
22
24
 
23
25
  ## Usage
24
26
 
@@ -35,10 +37,53 @@ ng <command> -h
35
37
  # Example:
36
38
  ng commit -h
37
39
  ng branch -h
40
+ ng blame -h
41
+ ng hist -h
38
42
  ```
39
43
 
40
44
  ---
41
45
 
46
+ ## Command Reference
47
+
48
+ ### Quick Overview
49
+
50
+ #### Top-Level Commands
51
+
52
+ | Command | Alias | Description |
53
+ |---------|-------|-------------|
54
+ | `ng pull` | `ng pl` | Pull git branch with auto stash/pop |
55
+ | `ng push` | `ng ps` | Push current branch to remote |
56
+ | `ng checkout` | `ng co` | Checkout a branch with auto stash/pop |
57
+ | `ng diff` | `ng di` | Show differences between branches or working directory |
58
+ | `ng merge` | `ng mg` | Merge branches with auto stash/pop |
59
+ | `ng stash` | `ng st` | Git stash management (see subcommands below) |
60
+ | `ng blame` | - | View file commit history with interactive navigation |
61
+ | `ng commit` | - | Interactive commit with conventional commits |
62
+ | `ng status` | `ng s` | Show working tree status (interactive viewer) |
63
+ | `ng hist` | `ng history` | Show git history with beautiful graph format |
64
+ | `ng config` | - | Interactive git configuration manager |
65
+
66
+ #### Branch Subcommands (`ng branch`)
67
+
68
+ | Command | Alias | Description |
69
+ |---------|-------|-------------|
70
+ | `ng branch clean` | - | Clean merged branches with time filtering |
71
+ | `ng branch delete` | - | Delete local/remote branches with merge status check |
72
+ | `ng branch list` | `ng branch ls` | List all branches with current indicator |
73
+
74
+ #### Stash Subcommands (`ng stash`)
75
+
76
+ | Command | Alias | Description |
77
+ |---------|-------|-------------|
78
+ | `ng stash save` | `ng stash s` | Save current changes to stash |
79
+ | `ng stash list` | `ng stash ls` | List all stashes |
80
+ | `ng stash pop` | `ng stash p` | Pop the most recent stash |
81
+ | `ng stash drop` | `ng stash d` | Drop/clear stashes |
82
+ | `ng stash clear` | `ng stash c` | Clear all stashes |
83
+ | `ng stash history` | `ng stash his` | View stash history from persistent index |
84
+
85
+ ---
86
+
42
87
  ## Commands
43
88
 
44
89
  ### Commit (`ng commit`)
@@ -188,21 +233,21 @@ ng branch clean
188
233
 
189
234
  ---
190
235
 
191
- ### List Branches (`ng list` / `ng ls`)
236
+ ### List Branches (`ng branch list` / `ng branch ls`)
192
237
 
193
238
  List branches with current branch indicator.
194
239
 
195
240
  ```bash
196
241
  # List all branches (default)
197
- ng list
242
+ ng branch list
198
243
 
199
244
  # Local branches only
200
- ng list -l
201
- ng list --local
245
+ ng branch list -l
246
+ ng branch list --local
202
247
 
203
248
  # Remote branches only
204
- ng list -r
205
- ng list --remote
249
+ ng branch list -r
250
+ ng branch list --remote
206
251
  ```
207
252
 
208
253
  **Features:**
@@ -239,6 +284,180 @@ ng merge -r
239
284
 
240
285
  ---
241
286
 
287
+ ### Interactive Commit Navigator (`ng blame`)
288
+
289
+ Browse file commit history with full diff support and interactive navigation.
290
+
291
+ ```bash
292
+ # View commit history for a file
293
+ ng blame <file-path>
294
+
295
+ # Example
296
+ ng blame src/commands/blame.ts
297
+ ng blame packages/git/src/commands/blame.ts
298
+ ```
299
+
300
+ **Features:**
301
+ - ✅ **Full Diff Display**: Shows complete diff for each commit (not just commit messages)
302
+ - ✅ **Interactive Navigation**: Browse through commits with keyboard shortcuts
303
+ - ✅ **Smart Caching**: Fetches git history once, then navigates instantly
304
+ - ✅ **Binary File Support**: Detects and handles binary files gracefully
305
+ - ✅ **Large Diff Protection**: Limits display to 50 lines to prevent terminal overflow
306
+ - ✅ **Follow File Renames**: Uses `--follow` to track history across renames
307
+
308
+ **Interactive Controls:**
309
+
310
+ | Key | Action | Description |
311
+ |-----|--------|-------------|
312
+ | `n` | Next commit | Move forward in time (to newer commits) |
313
+ | `p` | Previous commit | Move backward in time (to older commits) |
314
+ | `j` | Jump | Jump to a specific commit by number |
315
+ | `q` | Quit | Exit the navigator |
316
+
317
+ **Display Information:**
318
+
319
+ Each commit shows:
320
+ - 📝 Commit number (e.g., `Commit 3/10`)
321
+ - 🔖 Short commit hash (8 characters, colored)
322
+ - 👤 Author name (colored)
323
+ - 📅 Commit date (dimmed)
324
+ - 💬 Commit message
325
+ - 📄 Full diff with git standard formatting (red for deletions, green for additions)
326
+
327
+ **Special Handling:**
328
+
329
+ - **Binary Files**: Shows "📄 Binary file - diff not available" instead of binary content
330
+ - **Large Diffs**: Displays first 50 lines with truncation notice
331
+ ```
332
+ (Showing first 50 lines of 123)
333
+ ... (truncated)
334
+ ```
335
+ - **Empty History**: Warns if file has no git history
336
+ - **Missing Files**: Clear error if file doesn't exist
337
+
338
+ **Example Output:**
339
+
340
+ ```
341
+ Found 10 commits for src/commands/blame.ts
342
+ Use [n/p] to navigate, [j] to jump, [q] to quit
343
+
344
+ 📝 Commit 1/10
345
+ abc123de - John Doe - Mon Feb 2 12:00:00 2026
346
+ feat(git): add interactive commit navigator
347
+
348
+ --- Diff ---
349
+ diff --git a/src/commands/blame.ts b/src/commands/blame.ts
350
+ new file mode 100644
351
+ index 0000000..1234567
352
+ --- /dev/null
353
+ +++ b/src/commands/blame.ts
354
+ @@ -0,0 +1,315 @@
355
+ +import path from 'node:path'
356
+ +import readline from 'node:readline'
357
+ ...
358
+
359
+ --- Actions ---
360
+ [n] Next commit [p] Previous commit [j] Jump [q] Quit
361
+ ```
362
+
363
+ **Use Cases:**
364
+
365
+ - 📖 **Code Review**: Understand how a file evolved over time
366
+ - 🐛 **Bug Investigation**: Find when a specific line was changed
367
+ - 📚 **Learning**: Study the development history of a feature
368
+ - 🔍 **Audit**: Review all changes made to a critical file
369
+
370
+ ---
371
+
372
+ ### Git History Viewer (`ng hist` / `ng history`)
373
+
374
+ Display git history with an interactive, scrollable graph view.
375
+
376
+ ```bash
377
+ # Show full git history
378
+ ng hist
379
+
380
+ # Limit number of commits
381
+ ng hist -n 20
382
+ ng hist --number 50
383
+
384
+ # Using alias
385
+ ng history
386
+ ng history -n 10
387
+ ```
388
+
389
+ **Features:**
390
+ - ✅ **Beautiful Graph Format**: Visualizes branch structure with commit tree
391
+ - ✅ **Interactive Navigation**: Scroll through history with keyboard or mouse
392
+ - ✅ **Optimized Display**: Automatically adjusts to terminal size
393
+ - ✅ **Status Bar**: Shows current position and available shortcuts
394
+ - ✅ **Color-Coded Output**:
395
+ - Cyan: Commit hash
396
+ - Green: Commit date
397
+ - Magenta: Author name
398
+ - Yellow: Branch references
399
+
400
+ **Interactive Controls:**
401
+
402
+ | Key | Action | Description |
403
+ |-----|--------|-------------|
404
+ | `↑` / `k` | Scroll up | Move up through commits |
405
+ | `↓` / `j` | Scroll down | Move down through commits |
406
+ | `gg` | Jump to top | Go to the oldest commit |
407
+ | `G` | Jump to bottom | Go to the newest commit (Shift+G) |
408
+ | `Page Up` | Page up | Scroll up one page |
409
+ | `Page Down` | Page down | Scroll down one page |
410
+ | `q` / `Enter` | Quit | Exit the viewer |
411
+
412
+ **Display Information:**
413
+
414
+ Each commit shows:
415
+ - 🔖 Short commit hash (cyan, bold)
416
+ - 📅 Commit date and time (green)
417
+ - 👤 Author name (magenta)
418
+ - 🌿 Branch and tag references (yellow)
419
+ - 💬 Commit message
420
+
421
+ **Status Bar:**
422
+
423
+ ```
424
+ ↑↓/jk: Scroll | gg/G: Top/Bottom | PgUp/PgDn | q: Quit | Lines 1-42/150
425
+ ```
426
+
427
+ **Layout Optimization:**
428
+
429
+ - Automatically calculates optimal view height based on terminal size
430
+ - Reserves space for UI elements (borders, status bar)
431
+ - Ensures minimum of 10 lines for content display
432
+ - Removes unnecessary margins for maximum content visibility
433
+
434
+ **Use Cases:**
435
+
436
+ - 📊 **Project Overview**: Quickly see commit history and branch structure
437
+ - 🔍 **Context Browsing**: Understand recent changes before switching branches
438
+ - 📝 **Review History**: Check recent commits before pulling or pushing
439
+ - 🎯 **Navigation**: Find specific commits in the history
440
+
441
+ **Example Output:**
442
+
443
+ ```
444
+ ┌─────────────────────────────────────────────────────────────────┐
445
+ │* abc123de 2026-02-06 14:54:23 [GaoZimeng] (HEAD -> main) │
446
+ ││ refactor(git): main increase hist viewer height line │
447
+ │* 1a40997 2026-02-06 14:52:15 [GaoZimeng] │
448
+ ││ feat(git): fetch remote branches before pull │
449
+ │* a3be508 2026-02-06 14:51:23 [GaoZimeng] │
450
+ ││ refactor(git): change branch selection from search to select│
451
+ │* 172403f 2026-02-06 14:50:12 [GaoZimeng] │
452
+ ││ feat(git): enhance merge command with commit customization │
453
+ ├─────────────────────────────────────────────────────────────────┤
454
+ │ ↑↓/jk: Scroll | gg/G: Top/Bottom | PgUp/PgDn | q: Quit | Lines │
455
+ │ 1-10/150 │
456
+ └─────────────────────────────────────────────────────────────────┘
457
+ ```
458
+
459
+ ---
460
+
242
461
  ### Stash Operations (`ng stash` / `ng st`)
243
462
 
244
463
  Advanced stash management.
@@ -418,6 +637,93 @@ ng branch clean
418
637
  # Confirm deletion
419
638
  ```
420
639
 
640
+ ### Investigating File History
641
+
642
+ ```bash
643
+ # Understand how a file evolved over time
644
+ ng blame src/utils/date.ts
645
+
646
+ # Interactive navigation:
647
+ # - Press 'n' to see next commit
648
+ # - Press 'p' to go back to previous commit
649
+ # - Press 'j' to jump to commit 5/10
650
+ # - Press 'q' when done reviewing
651
+
652
+ # Each commit shows:
653
+ # - Full commit hash, author, date, message
654
+ # - Complete diff (what changed)
655
+ # - Current position (e.g., "Commit 3/10")
656
+ ```
657
+
658
+ **Real-world scenarios:**
659
+
660
+ - 🐛 **Bug Investigation**: Find when a bug was introduced
661
+ ```bash
662
+ ng blame src/auth/login.ts
663
+ # Press 'n' repeatedly to review changes chronologically
664
+ # Look for the commit that broke the functionality
665
+ ```
666
+
667
+ - 📖 **Code Review**: Understand the evolution of a complex function
668
+ ```bash
669
+ ng blame src/api/handlers.ts
670
+ # Navigate through commits to see how the logic developed
671
+ ```
672
+
673
+ - 🔍 **Audit Trail**: Review all changes to a security-critical file
674
+ ```bash
675
+ ng blame src/config/security.ts
676
+ # Use 'j' to jump to specific commits of interest
677
+ ```
678
+
679
+ ---
680
+
681
+ ### Browsing Project History
682
+
683
+ ```bash
684
+ # View full git history with beautiful graph
685
+ ng hist
686
+
687
+ # View last 20 commits
688
+ ng hist -n 20
689
+
690
+ # Interactive navigation:
691
+ # - Use ↑/↓ or j/k to scroll through commits
692
+ # - Press 'gg' to jump to oldest commit
693
+ # - Press 'G' (Shift+G) to jump to newest commit
694
+ # - Use Page Up/Down to scroll by pages
695
+ # - Press 'q' or Enter to exit
696
+
697
+ # Features:
698
+ # - Color-coded output (hash, date, author, branches)
699
+ # - Visual commit graph showing branch structure
700
+ # - Status bar showing current position
701
+ # - Automatically adjusts to terminal size
702
+ ```
703
+
704
+ **Real-world scenarios:**
705
+
706
+ - 📊 **Before Pulling**: Check what's been committed recently
707
+ ```bash
708
+ ng hist -n 10
709
+ # Review recent commits before doing `ng pull`
710
+ ```
711
+
712
+ - 🎯 **Finding Commits**: Locate a specific commit in history
713
+ ```bash
714
+ ng hist
715
+ # Press 'gg' to go to oldest commit
716
+ # Use ↓/j to scroll forward to find what you need
717
+ # Note the commit hash (e.g., abc123de)
718
+ ```
719
+
720
+ - 🌿 **Branch Overview**: Understand branch structure and merges
721
+ ```bash
722
+ ng hist -n 50
723
+ # See how branches diverged and merged
724
+ # Identify branch points and merge commits
725
+ ```
726
+
421
727
  ---
422
728
 
423
729
  ## Comparison: Git vs `ng`
@@ -429,9 +735,21 @@ ng branch clean
429
735
  | Push | `git push` | `ng push` (interactive) |
430
736
  | Checkout | `git checkout` | `ng checkout` (auto stash + interactive) |
431
737
  | Branch delete | `git branch -D` | `ng branch delete` (merge status check) |
432
- | List branches | `git branch` | `ng list` (enhanced display) |
738
+ | List branches | `git branch` | `ng branch list` (enhanced display) |
433
739
  | Merge | `git merge` | `ng merge` (auto stash + searchable) |
434
740
  | Stash | `git stash` | `ng stash` (enhanced management) |
741
+ | Blame | `git blame` (line-by-line) | `ng blame` (full commit history with diff) |
742
+ | Log/History | `git log` (static output) | `ng hist` (interactive graph viewer) |
743
+
744
+ **Key Difference - `ng blame` vs `git blame`:**
745
+
746
+ | Feature | `git blame` | `ng blame` |
747
+ |---------|-------------|------------|
748
+ | Shows | Line-by-line annotations | Full commit history with diffs |
749
+ | Navigation | Scroll through file | Interactive commit navigation (n/p/j/q) |
750
+ | Diff View | No (use separately) | Yes, included for each commit |
751
+ | File Renames | Limited | Full support with `--follow` |
752
+ | Best For | Finding who changed a line | Understanding file evolution |
435
753
 
436
754
  ---
437
755
 
@@ -0,0 +1,32 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region \0rolldown/runtime.js
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ }
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
+
31
+ //#endregion
32
+ export { __require as n, __toESM as r, __commonJSMin as t };