gitxplain 0.1.8 → 0.2.0

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.
@@ -16,6 +16,8 @@ jobs:
16
16
  with:
17
17
  node-version: '20'
18
18
  cache: npm
19
+ registry-url: 'https://registry.npmjs.org'
20
+ always-auth: true
19
21
  - name: Install dependencies
20
22
  run: npm ci
21
23
  - name: Lint
@@ -2,12 +2,13 @@ name: Release
2
2
  on:
3
3
  push:
4
4
  tags:
5
- - '*.*.*'
5
+ - 'v*'
6
+ permissions:
7
+ contents: write
6
8
  jobs:
7
- publish:
9
+ release:
10
+ if: startsWith(github.ref_name, 'v')
8
11
  runs-on: ubuntu-latest
9
- permissions:
10
- contents: read
11
12
  steps:
12
13
  - name: Checkout
13
14
  uses: actions/checkout@v4
@@ -16,12 +17,98 @@ jobs:
16
17
  with:
17
18
  node-version: '20'
18
19
  cache: npm
19
- registry-url: 'https://registry.npmjs.org/'
20
+ registry-url: 'https://registry.npmjs.org'
21
+ always-auth: true
20
22
  - name: Install dependencies
21
23
  run: npm ci
24
+ - name: Derive release metadata
25
+ id: meta
26
+ run: |
27
+ VERSION="${GITHUB_REF_NAME#v}"
28
+ echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
29
+ echo "deb_path=dist/gitxplain_${VERSION}_all.deb" >> "${GITHUB_OUTPUT}"
22
30
  - name: Test
23
31
  run: npm test
32
+ - name: Build Debian package
33
+ run: ./scripts/build-deb.sh
34
+ - name: Verify npm token
35
+ env:
36
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
37
+ run: |
38
+ if [ -z "${NODE_AUTH_TOKEN}" ]; then
39
+ echo "NPM_TOKEN is not configured for this repository."
40
+ echo "Add it in GitHub: Settings -> Secrets and variables -> Actions -> New repository secret."
41
+ exit 1
42
+ fi
43
+ printf "//registry.npmjs.org/:_authToken=%s\n" "${NODE_AUTH_TOKEN}" > "${HOME}/.npmrc"
44
+ npm whoami
24
45
  - name: Publish to npm
25
46
  env:
26
47
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
27
48
  run: npm publish
49
+ - name: Compute npm tarball SHA-256
50
+ id: npm
51
+ run: |
52
+ VERSION="${{ steps.meta.outputs.version }}"
53
+ TARBALL_URL="https://registry.npmjs.org/gitxplain/-/gitxplain-${VERSION}.tgz"
54
+ curl -fsSL "${TARBALL_URL}" -o "gitxplain-${VERSION}.tgz"
55
+ SHA256="$(sha256sum "gitxplain-${VERSION}.tgz" | awk '{print $1}')"
56
+ echo "tarball_url=${TARBALL_URL}" >> "${GITHUB_OUTPUT}"
57
+ echo "sha256=${SHA256}" >> "${GITHUB_OUTPUT}"
58
+ - name: Checkout Homebrew tap
59
+ uses: actions/checkout@v4
60
+ with:
61
+ repository: guruswarupa/homebrew-tap
62
+ token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
63
+ path: homebrew-tap
64
+ - name: Update Homebrew formula
65
+ run: |
66
+ VERSION="${{ steps.meta.outputs.version }}"
67
+ SHA256="${{ steps.npm.outputs.sha256 }}"
68
+ FORMULA_PATH="homebrew-tap/Formula/gitxplain.rb"
69
+ mkdir -p "$(dirname "${FORMULA_PATH}")"
70
+ cat > "${FORMULA_PATH}" <<EOF
71
+ class Gitxplain < Formula
72
+ desc "AI-powered Git commit explainer CLI"
73
+ homepage "https://github.com/guruswarupa/gitxplain"
74
+ url "https://registry.npmjs.org/gitxplain/-/gitxplain-${VERSION}.tgz"
75
+ sha256 "${SHA256}"
76
+ license "MIT"
77
+
78
+ depends_on "node"
79
+
80
+ def install
81
+ libexec.install Dir["package/*"]
82
+ bin.install_symlink libexec/"cli/index.js" => "gitxplain"
83
+ bin.install_symlink libexec/"cli/index.js" => "gitxplore"
84
+ end
85
+
86
+ test do
87
+ assert_match "gitxplain", shell_output("#{bin}/gitxplain --help")
88
+ end
89
+ end
90
+ EOF
91
+ - name: Commit and push Homebrew tap changes
92
+ working-directory: homebrew-tap
93
+ run: |
94
+ git config user.name "github-actions[bot]"
95
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
96
+ git add Formula/gitxplain.rb
97
+ if git diff --cached --quiet; then
98
+ echo "No Homebrew formula changes to commit."
99
+ exit 0
100
+ fi
101
+ git commit -m "gitxplain ${GITHUB_REF_NAME}"
102
+ git push
103
+ - name: Create GitHub release and upload Debian package
104
+ uses: softprops/action-gh-release@v2
105
+ with:
106
+ files: ${{ steps.meta.outputs.deb_path }}
107
+ - name: Print AUR update instructions
108
+ run: |
109
+ VERSION="${{ steps.meta.outputs.version }}"
110
+ SHA256="${{ steps.npm.outputs.sha256 }}"
111
+ echo "Manual AUR update steps:"
112
+ echo "1. Update packaging/aur/PKGBUILD with pkgver=${VERSION} and sha256sums=('${SHA256}')."
113
+ echo "2. Run: makepkg --printsrcinfo > .SRCINFO"
114
+ echo "3. Commit PKGBUILD and .SRCINFO to the AUR git repository and push."
package/README.md CHANGED
@@ -10,18 +10,26 @@ Supported providers:
10
10
  - Gemini
11
11
  - Ollama
12
12
  - Chutes AI
13
+ - Anthropic
14
+ - Mistral
15
+ - Azure OpenAI
13
16
 
14
17
  ## Features
15
18
 
16
19
  - Explains what a commit does, why it exists, and how the fix works
17
20
  - Supports focused output modes like summary, issue, fix, impact, review, security, and line-by-line walkthroughs
21
+ - Supports blame summaries, changelog drafting, PR description drafting, refactor suggestions, and test suggestion modes
22
+ - Supports stash explanation and single-file diff deep dives
23
+ - Supports merge conflict analysis with suggested resolutions
24
+ - Supports cumulative token usage tracking and optional estimated cost reporting
25
+ - Supports interactive split-plan review before history is rewritten
18
26
  - Supports AI-assisted commit splitting plans, with optional execution for the latest commit
19
27
  - Supports release-branch merge previews driven by detected version bumps in diffs
20
28
  - Supports automatic release tagging driven by the same version-bump detection used for release merges
21
29
  - Supports release health status checks that show missing tags, unmerged version bumps, branch drift, and next steps
22
30
  - Supports AI-assisted commit planning for uncommitted working tree changes
23
31
  - Supports quick repository log output for full history inspection
24
- - Supports repository-aware CI/CD workflow generation for the repo you are currently in
32
+ - Supports repository-aware CI/CD workflow generation for GitHub Actions, GitLab CI, CircleCI, and Bitbucket Pipelines
25
33
  - Supports single commits, commit ranges, and branch-vs-base comparisons
26
34
  - Truncates oversized diffs before sending them to the model and reports that truncation
27
35
  - Streams output for supported providers
@@ -38,6 +46,43 @@ Supported providers:
38
46
  - A Git repository in your current working directory
39
47
  - An API key for your chosen provider, or a local Ollama instance
40
48
 
49
+ ## Installation
50
+
51
+ Install from npm:
52
+
53
+ ```bash
54
+ npm install -g gitxplain
55
+ ```
56
+
57
+ Install from bun:
58
+
59
+ ```bash
60
+ bun install -g gitxplain
61
+ ```
62
+
63
+ Install with Homebrew:
64
+
65
+ ```bash
66
+ brew tap guruswarupa/homebrew-tap
67
+ brew install gitxplain
68
+ ```
69
+
70
+ Install from the AUR:
71
+
72
+ ```bash
73
+ yay -S gitxplain
74
+ ```
75
+
76
+ ```bash
77
+ paru -S gitxplain
78
+ ```
79
+
80
+ Install from a Debian package downloaded from GitHub Releases:
81
+
82
+ ```bash
83
+ sudo apt install ./gitxplain_<version>_all.deb
84
+ ```
85
+
41
86
  Optional advanced environment variables:
42
87
 
43
88
  - `LLM_PROVIDER` default: `openai`
@@ -70,6 +115,19 @@ Show the built-in command reference.
70
115
  gitxplain --help
71
116
  ```
72
117
 
118
+ Inspect cache usage or clear cached responses.
119
+
120
+ ```bash
121
+ gitxplain cache stats
122
+ gitxplain cache clear
123
+ ```
124
+
125
+ Show cumulative token usage and estimated cost totals.
126
+
127
+ ```bash
128
+ gitxplain --cost
129
+ ```
130
+
73
131
  Save the default AI provider.
74
132
 
75
133
  ```bash
@@ -142,6 +200,13 @@ Preview or create release tags.
142
200
  gitxplain --tag
143
201
  ```
144
202
 
203
+ Explain the latest stash, or a specific stash entry.
204
+
205
+ ```bash
206
+ gitxplain --stash
207
+ gitxplain --stash stash@{2}
208
+ ```
209
+
145
210
  Print repository log output.
146
211
 
147
212
  ```bash
@@ -160,6 +225,21 @@ Detect and generate CI/CD workflow files.
160
225
  gitxplain --pipeline
161
226
  ```
162
227
 
228
+ Analyze unresolved merge conflicts in the working tree.
229
+
230
+ ```bash
231
+ gitxplain --conflict
232
+ gitxplain --conflict --diff src/auth.js
233
+ ```
234
+
235
+ Install a git hook for commit, merge, or push workflows.
236
+
237
+ ```bash
238
+ gitxplain install-hook
239
+ gitxplain install-hook post-merge
240
+ gitxplain install-hook pre-push
241
+ ```
242
+
163
243
  Analysis:
164
244
 
165
245
  Generate a one-line summary.
@@ -210,6 +290,48 @@ Focus on security-relevant changes.
210
290
  --security
211
291
  ```
212
292
 
293
+ Suggest refactoring follow-ups.
294
+
295
+ ```bash
296
+ --refactor
297
+ ```
298
+
299
+ Suggest tests to add or update.
300
+
301
+ ```bash
302
+ --test-suggest
303
+ ```
304
+
305
+ Generate a PR description.
306
+
307
+ ```bash
308
+ --pr-description
309
+ ```
310
+
311
+ Generate changelog-style notes.
312
+
313
+ ```bash
314
+ --changelog
315
+ ```
316
+
317
+ Analyze file ownership with git blame.
318
+
319
+ ```bash
320
+ --blame <file>
321
+ ```
322
+
323
+ Suggest resolutions for unresolved merge conflicts.
324
+
325
+ ```bash
326
+ --conflict
327
+ ```
328
+
329
+ Focus analysis on one changed file.
330
+
331
+ ```bash
332
+ --diff <file>
333
+ ```
334
+
213
335
  Propose splitting a commit into smaller commits.
214
336
 
215
337
  ```bash
@@ -234,6 +356,12 @@ Preview a plan without applying it.
234
356
  --dry-run
235
357
  ```
236
358
 
359
+ Review or edit a split plan before execution.
360
+
361
+ ```bash
362
+ --interactive
363
+ ```
364
+
237
365
  Release:
238
366
 
239
367
  Show release status details.
@@ -398,6 +526,18 @@ Stream model output as it arrives.
398
526
  --stream
399
527
  ```
400
528
 
529
+ Bypass cached responses for one command.
530
+
531
+ ```bash
532
+ --no-cache
533
+ ```
534
+
535
+ Show cumulative token usage and estimated cost totals.
536
+
537
+ ```bash
538
+ --cost
539
+ ```
540
+
401
541
  Limit diff size before sending it to the model.
402
542
 
403
543
  ```bash
@@ -423,6 +563,17 @@ gitxplain a1b2c3d --summary
423
563
  gitxplain HEAD~1 --lines
424
564
  gitxplain HEAD~5..HEAD --markdown
425
565
  gitxplain --branch main --review
566
+ gitxplain --branch main --pr-description
567
+ gitxplain HEAD~10..HEAD --changelog
568
+ gitxplain HEAD --refactor
569
+ gitxplain HEAD --test-suggest
570
+ gitxplain --blame cli/index.js
571
+ gitxplain --conflict
572
+ gitxplain --stash
573
+ gitxplain HEAD~5..HEAD --lines --diff cli/index.js
574
+ gitxplain --cost
575
+ gitxplain HEAD --split --interactive --execute
576
+ gitxplain install-hook post-merge
426
577
  ```
427
578
 
428
579
  If you do not want to link it globally, you can still run it locally:
@@ -441,14 +592,24 @@ node ./cli/index.js HEAD~1 --full
441
592
  - `--lines`: file-by-file, line-by-line walkthrough of the changed code
442
593
  - `--review`: code review findings with actionable suggestions
443
594
  - `--security`: security-focused analysis of the change
595
+ - `--refactor`: suggest maintainability-focused refactors visible in the change
596
+ - `--test-suggest`: suggest the most valuable tests to add or update
597
+ - `--pr-description`: draft a ready-to-paste pull request description
598
+ - `--changelog`: generate changelog-style release notes from the change set
599
+ - `--blame <file>`: summarize ownership and change history for one file using `git blame`
600
+ - `--conflict`: inspect unresolved merge conflicts and suggest likely resolutions
601
+ - `--stash [ref]`: explain what is stored in a stash entry, defaulting to `stash@{0}`
602
+ - `--diff <file>`: focus commit or range analysis on a single file
444
603
  - `--split`: propose how to split a commit into multiple atomic commits
604
+ - `--interactive`: review or edit a split plan before executing it
605
+ - `--cost`: show cumulative token usage and estimated cost totals
445
606
  - `--merge`: preview or execute a merge into the `release` branch based on detected version bumps
446
607
  - `--tag`: preview or create release tags from the same detected version windows
447
608
  - `--release [status]`: inspect release branch health, missing tags, source-vs-release drift, and the next recommended action
448
609
  - `--commit`: propose commits for current uncommitted changes
449
610
  - `--log`: print Git log entries for the current repository
450
611
  - `--status`: print Git working tree status for the current repository
451
- - `--pipeline`: inspect the current repository and generate GitHub Actions CI/CD workflows
612
+ - `--pipeline`: inspect the current repository and generate GitHub Actions, GitLab CI, CircleCI, or Bitbucket Pipelines config
452
613
  - `--execute`: apply a proposed split by rewriting history
453
614
  - `--dry-run`: preview the split or commit plan without applying it
454
615
  - `--json`: return structured JSON instead of formatted text
@@ -471,6 +632,9 @@ Run a few common Git actions directly through `gitxplain`:
471
632
 
472
633
  ```bash
473
634
  gitxplain --status
635
+ gitxplain cache stats
636
+ gitxplain cache clear
637
+ gitxplain --cost
474
638
  gitxplain add README.md
475
639
  gitxplain remove README.md
476
640
  gitxplain remove hard
@@ -538,13 +702,19 @@ Actually split the current `HEAD` commit into smaller commits:
538
702
  gitxplain HEAD --split --execute
539
703
  ```
540
704
 
705
+ Review the plan interactively before executing it:
706
+
707
+ ```bash
708
+ gitxplain HEAD --split --interactive --execute
709
+ ```
710
+
541
711
  Use a specific provider for the analysis:
542
712
 
543
713
  ```bash
544
714
  gitxplain HEAD --split --provider gemini
545
715
  ```
546
716
 
547
- `--split` asks the model for a plan first. By default this is a dry run and only prints the proposed commit breakdown. Adding `--execute` rewrites Git history by undoing the current `HEAD` commit and recreating it as multiple commits in the suggested order.
717
+ `--split` asks the model for a plan first. By default this is a dry run and only prints the proposed commit breakdown. Adding `--execute` rewrites Git history by undoing the current `HEAD` commit and recreating it as multiple commits in the suggested order. Adding `--interactive` lets you keep, edit, skip, or abort individual split groups before the rewrite happens.
548
718
 
549
719
  Warning: `--split --execute` rewrites history. If the commit was already pushed, you may need to force-push after reviewing the new commit stack. For safety, execution only supports splitting the current `HEAD` commit and requires a clean working tree.
550
720
 
@@ -631,7 +801,7 @@ gitxplain config set model gpt-4.1-mini
631
801
  gitxplain config list
632
802
  ```
633
803
 
634
- ## Clipboard, Streaming, And Hooks
804
+ ## Clipboard, Streaming, Cost, And Hooks
635
805
 
636
806
  Copy the final output to your clipboard:
637
807
 
@@ -645,12 +815,30 @@ Stream long responses as they arrive:
645
815
  gitxplain HEAD~1 --full --stream
646
816
  ```
647
817
 
818
+ Show cumulative usage and estimated cost totals:
819
+
820
+ ```bash
821
+ gitxplain --cost
822
+ ```
823
+
648
824
  Install a post-commit hook that saves a Markdown explanation under `.git/gitxplain/last-explanation.md`:
649
825
 
650
826
  ```bash
651
827
  gitxplain install-hook
652
828
  ```
653
829
 
830
+ Install a post-merge hook that explains the new `HEAD` after merges:
831
+
832
+ ```bash
833
+ gitxplain install-hook post-merge
834
+ ```
835
+
836
+ Install a pre-push hook that runs a security-oriented review:
837
+
838
+ ```bash
839
+ gitxplain install-hook pre-push
840
+ ```
841
+
654
842
  ## Provider Setup
655
843
 
656
844
  Recommended persistent setup:
@@ -673,6 +861,41 @@ gitxplain config set provider groq
673
861
  gitxplain config set api-key your_key
674
862
  ```
675
863
 
864
+ Additional supported providers:
865
+
866
+ ```bash
867
+ gitxplain config set provider anthropic
868
+ gitxplain config set api-key your_key
869
+
870
+ gitxplain config set provider mistral
871
+ gitxplain config set api-key your_key
872
+
873
+ gitxplain config set provider azure-openai
874
+ gitxplain config set api-key your_key
875
+ ```
876
+
877
+ Azure OpenAI also requires endpoint configuration:
878
+
879
+ ```bash
880
+ export AZURE_OPENAI_BASE_URL="https://your-resource.openai.azure.com"
881
+ export AZURE_OPENAI_DEPLOYMENT="your-deployment-name"
882
+ export AZURE_OPENAI_API_VERSION="2024-10-21"
883
+ ```
884
+
885
+ Optional token pricing env vars for estimated cost tracking:
886
+
887
+ ```bash
888
+ export OPENAI_INPUT_COST_PER_MTOK="0.15"
889
+ export OPENAI_OUTPUT_COST_PER_MTOK="0.60"
890
+ ```
891
+
892
+ Or use generic pricing defaults across providers:
893
+
894
+ ```bash
895
+ export LLM_INPUT_COST_PER_MTOK="0.15"
896
+ export LLM_OUTPUT_COST_PER_MTOK="0.60"
897
+ ```
898
+
676
899
  If you want to inspect what is saved:
677
900
 
678
901
  ```bash