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.
- package/.github/workflows/ci.yml +2 -0
- package/.github/workflows/release.yml +92 -5
- package/README.md +227 -4
- package/cli/index.js +439 -114
- package/cli/services/aiService.js +234 -28
- package/cli/services/cacheService.js +92 -1
- package/cli/services/clipboardService.js +6 -1
- package/cli/services/colorSupport.js +31 -0
- package/cli/services/commitService.js +105 -23
- package/cli/services/configService.js +18 -2
- package/cli/services/envLoader.js +2 -2
- package/cli/services/gitService.js +369 -23
- package/cli/services/hookService.js +36 -4
- package/cli/services/mergeService.js +43 -30
- package/cli/services/outputFormatter.js +23 -73
- package/cli/services/pipelineService.js +344 -9
- package/cli/services/promptService.js +8 -1
- package/cli/services/splitService.js +1 -21
- package/cli/services/usageService.js +158 -0
- package/package.json +4 -4
- package/packaging/README.md +60 -0
- package/packaging/aur/.SRCINFO +12 -0
- package/packaging/aur/PKGBUILD +22 -0
- package/packaging/homebrew-tap/Formula/gitxplain.rb +19 -0
- package/prompts/blame.txt +29 -0
- package/prompts/changelog.txt +36 -0
- package/prompts/conflict.txt +33 -0
- package/prompts/pr-description.txt +40 -0
- package/prompts/refactor.txt +29 -0
- package/prompts/stash.txt +34 -0
- package/prompts/test-suggest.txt +29 -0
- package/scripts/build-deb.sh +64 -0
- package/IMPLEMENTATION.md +0 -225
- package/cli/services/chatService.js +0 -683
- package/cli/services/gitConnectionService.js +0 -267
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitxplain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "AI-powered Git commit explainer CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"gitxplain": "
|
|
8
|
-
"gitxplore": "
|
|
7
|
+
"gitxplain": "cli/index.js",
|
|
8
|
+
"gitxplore": "cli/index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "node ./cli/index.js",
|
|
12
|
-
"lint": "node --check ./cli/index.js && node --check ./cli/services/
|
|
12
|
+
"lint": "node --check ./cli/index.js && node --check ./cli/services/envLoader.js && node --check ./cli/services/pipelineService.js",
|
|
13
13
|
"test": "node --test"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Packaging
|
|
2
|
+
|
|
3
|
+
This directory contains packaging assets for Homebrew, AUR, and Debian releases.
|
|
4
|
+
|
|
5
|
+
## Homebrew tap
|
|
6
|
+
|
|
7
|
+
Template formula: `packaging/homebrew-tap/Formula/gitxplain.rb`
|
|
8
|
+
|
|
9
|
+
Create and publish the tap repository:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
gh repo create guruswarupa/homebrew-tap --public --clone
|
|
13
|
+
cd homebrew-tap
|
|
14
|
+
mkdir -p Formula
|
|
15
|
+
cp /path/to/gitxplain/packaging/homebrew-tap/Formula/gitxplain.rb Formula/gitxplain.rb
|
|
16
|
+
git add Formula/gitxplain.rb
|
|
17
|
+
git commit -m "Add gitxplain formula"
|
|
18
|
+
git push -u origin main
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
After each new npm publish, update the formula `url` and replace `"<SHA256_PLACEHOLDER>"` with the tarball SHA-256, then push the change.
|
|
22
|
+
|
|
23
|
+
## AUR
|
|
24
|
+
|
|
25
|
+
Template files:
|
|
26
|
+
|
|
27
|
+
- `packaging/aur/PKGBUILD`
|
|
28
|
+
- `packaging/aur/.SRCINFO`
|
|
29
|
+
|
|
30
|
+
Generate `.SRCINFO` after updating `PKGBUILD`:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd /path/to/gitxplain/packaging/aur
|
|
34
|
+
makepkg --printsrcinfo > .SRCINFO
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Create and publish the AUR package:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone ssh://aur@aur.archlinux.org/gitxplain.git aur-gitxplain
|
|
41
|
+
cd aur-gitxplain
|
|
42
|
+
cp /path/to/gitxplain/packaging/aur/PKGBUILD .
|
|
43
|
+
cp /path/to/gitxplain/packaging/aur/.SRCINFO .
|
|
44
|
+
makepkg --printsrcinfo > .SRCINFO
|
|
45
|
+
git add PKGBUILD .SRCINFO
|
|
46
|
+
git commit -m "Initial gitxplain release"
|
|
47
|
+
git push
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Replace `"<SHA256_PLACEHOLDER>"` with the npm tarball SHA-256 before publishing.
|
|
51
|
+
|
|
52
|
+
## Debian
|
|
53
|
+
|
|
54
|
+
Build the Debian package from this repository:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
./scripts/build-deb.sh
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The package is written to `dist/gitxplain_<version>_all.deb`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
pkgbase = gitxplain
|
|
2
|
+
pkgdesc = AI-powered Git commit explainer CLI
|
|
3
|
+
pkgver = 0.1.9
|
|
4
|
+
pkgrel = 1
|
|
5
|
+
url = https://github.com/guruswarupa/gitxplain
|
|
6
|
+
arch = any
|
|
7
|
+
license = MIT
|
|
8
|
+
depends = nodejs
|
|
9
|
+
source = https://registry.npmjs.org/gitxplain/-/gitxplain-0.1.9.tgz
|
|
10
|
+
sha256sums = <SHA256_PLACEHOLDER>
|
|
11
|
+
|
|
12
|
+
pkgname = gitxplain
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
pkgname=gitxplain
|
|
2
|
+
pkgver=0.1.9
|
|
3
|
+
pkgrel=1
|
|
4
|
+
pkgdesc="AI-powered Git commit explainer CLI"
|
|
5
|
+
arch=('any')
|
|
6
|
+
url="https://github.com/guruswarupa/gitxplain"
|
|
7
|
+
license=('MIT')
|
|
8
|
+
depends=('nodejs')
|
|
9
|
+
source=("https://registry.npmjs.org/${pkgname}/-/${pkgname}-${pkgver}.tgz")
|
|
10
|
+
sha256sums=('<SHA256_PLACEHOLDER>')
|
|
11
|
+
|
|
12
|
+
package() {
|
|
13
|
+
install -d "${pkgdir}/usr/lib/${pkgname}"
|
|
14
|
+
tar -xzf "${srcdir}/${pkgname}-${pkgver}.tgz" -C "${srcdir}"
|
|
15
|
+
cp -a "${srcdir}/package/." "${pkgdir}/usr/lib/${pkgname}/"
|
|
16
|
+
|
|
17
|
+
chmod 755 "${pkgdir}/usr/lib/${pkgname}/cli/index.js"
|
|
18
|
+
|
|
19
|
+
install -d "${pkgdir}/usr/bin"
|
|
20
|
+
ln -sf "/usr/lib/${pkgname}/cli/index.js" "${pkgdir}/usr/bin/gitxplain"
|
|
21
|
+
ln -sf "/usr/lib/${pkgname}/cli/index.js" "${pkgdir}/usr/bin/gitxplore"
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Gitxplain < Formula
|
|
2
|
+
desc "AI-powered Git commit explainer CLI"
|
|
3
|
+
homepage "https://github.com/guruswarupa/gitxplain"
|
|
4
|
+
url "https://registry.npmjs.org/gitxplain/-/gitxplain-0.1.9.tgz"
|
|
5
|
+
sha256 "<SHA256_PLACEHOLDER>"
|
|
6
|
+
license "MIT"
|
|
7
|
+
|
|
8
|
+
depends_on "node"
|
|
9
|
+
|
|
10
|
+
def install
|
|
11
|
+
libexec.install Dir["package/*"]
|
|
12
|
+
bin.install_symlink libexec/"cli/index.js" => "gitxplain"
|
|
13
|
+
bin.install_symlink libexec/"cli/index.js" => "gitxplore"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test do
|
|
17
|
+
assert_match "gitxplain", shell_output("#{bin}/gitxplain --help")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Analyze this git blame report for a file and explain ownership patterns.
|
|
2
|
+
|
|
3
|
+
Context:
|
|
4
|
+
- The input below is not a diff. It is a compact blame summary built from `git blame --line-porcelain`.
|
|
5
|
+
- Focus on who changed which parts of the file, when the major edits happened, and what kinds of changes appear to have shaped the file.
|
|
6
|
+
- Call out concentrated ownership, legacy areas, and spots that may need extra care during onboarding or refactoring.
|
|
7
|
+
|
|
8
|
+
Commit Message:
|
|
9
|
+
{{commit_message}}
|
|
10
|
+
|
|
11
|
+
Files Changed:
|
|
12
|
+
{{files_changed}}
|
|
13
|
+
|
|
14
|
+
Stats:
|
|
15
|
+
{{stats}}
|
|
16
|
+
|
|
17
|
+
Blame Report:
|
|
18
|
+
{{diff}}
|
|
19
|
+
|
|
20
|
+
Return:
|
|
21
|
+
|
|
22
|
+
1. Ownership Summary:
|
|
23
|
+
- Summarize the main authors or time periods that shaped the file
|
|
24
|
+
|
|
25
|
+
2. Likely Change Themes:
|
|
26
|
+
- Explain what kinds of changes the major contributors appear to have made
|
|
27
|
+
|
|
28
|
+
3. Onboarding Notes:
|
|
29
|
+
- Suggest where a new maintainer should read carefully, who to ask first, or what parts look risky or stable
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Generate release notes in a conventional-changelog style.
|
|
2
|
+
|
|
3
|
+
Context:
|
|
4
|
+
- This may represent a single commit or a range of commits.
|
|
5
|
+
- Prefer grouping entries under headings like Features, Fixes, Refactors, Docs, Tests, Chores, and Breaking Changes when supported by the evidence.
|
|
6
|
+
- Use commit messages first, then use the diff to sharpen unclear items.
|
|
7
|
+
- Be conservative and do not invent user-facing changes that are not visible in the Git data.
|
|
8
|
+
|
|
9
|
+
Commit Message:
|
|
10
|
+
{{commit_message}}
|
|
11
|
+
|
|
12
|
+
Files Changed:
|
|
13
|
+
{{files_changed}}
|
|
14
|
+
|
|
15
|
+
Stats:
|
|
16
|
+
{{stats}}
|
|
17
|
+
|
|
18
|
+
Change Hints:
|
|
19
|
+
{{change_hints}}
|
|
20
|
+
|
|
21
|
+
Diff:
|
|
22
|
+
{{diff}}
|
|
23
|
+
|
|
24
|
+
Return:
|
|
25
|
+
|
|
26
|
+
1. Release Summary:
|
|
27
|
+
- One short paragraph describing the overall release/change set
|
|
28
|
+
|
|
29
|
+
2. Changelog:
|
|
30
|
+
- Group entries under relevant categories
|
|
31
|
+
- Keep bullets concise and user-facing
|
|
32
|
+
- If there are no clear entries for a category, omit it
|
|
33
|
+
|
|
34
|
+
3. Upgrade Notes:
|
|
35
|
+
- Mention any migration steps, rollout cautions, or compatibility risks
|
|
36
|
+
- If none are apparent, say so clearly
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
You are helping resolve unresolved Git merge conflicts.
|
|
2
|
+
|
|
3
|
+
Context:
|
|
4
|
+
- The input below is a structured report extracted from conflict markers in the working tree.
|
|
5
|
+
- Explain what each side appears to be doing, suggest the most likely safe resolution, and call out any ambiguity that requires human review.
|
|
6
|
+
- Be conservative. Do not pretend a single resolution is certain when the intent is unclear.
|
|
7
|
+
|
|
8
|
+
Conflict Summary:
|
|
9
|
+
{{commit_message}}
|
|
10
|
+
|
|
11
|
+
Files Changed:
|
|
12
|
+
{{files_changed}}
|
|
13
|
+
|
|
14
|
+
Stats:
|
|
15
|
+
{{stats}}
|
|
16
|
+
|
|
17
|
+
Conflict Report:
|
|
18
|
+
{{diff}}
|
|
19
|
+
|
|
20
|
+
Return:
|
|
21
|
+
|
|
22
|
+
1. Conflict Summary:
|
|
23
|
+
- Explain the overall source of the conflict
|
|
24
|
+
|
|
25
|
+
2. Suggested Resolution:
|
|
26
|
+
- For each file or conflict block, describe the most likely resolution
|
|
27
|
+
- Be explicit about which lines to keep, merge, or rewrite
|
|
28
|
+
|
|
29
|
+
3. Why:
|
|
30
|
+
- Explain why the suggested resolution is the safest or most consistent
|
|
31
|
+
|
|
32
|
+
4. Follow-Up Checks:
|
|
33
|
+
- Suggest tests, manual verification steps, or edge cases to validate after resolving the conflict
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Write a pull request description for this change set.
|
|
2
|
+
|
|
3
|
+
Context:
|
|
4
|
+
- This may be a single commit, a commit range, or a branch comparison.
|
|
5
|
+
- The result should be ready to paste into GitHub or GitLab.
|
|
6
|
+
- Be accurate and concise. Do not invent testing or screenshots that are not evidenced by the diff.
|
|
7
|
+
|
|
8
|
+
Commit Message:
|
|
9
|
+
{{commit_message}}
|
|
10
|
+
|
|
11
|
+
Files Changed:
|
|
12
|
+
{{files_changed}}
|
|
13
|
+
|
|
14
|
+
Stats:
|
|
15
|
+
{{stats}}
|
|
16
|
+
|
|
17
|
+
Change Hints:
|
|
18
|
+
{{change_hints}}
|
|
19
|
+
|
|
20
|
+
Diff:
|
|
21
|
+
{{diff}}
|
|
22
|
+
|
|
23
|
+
Return:
|
|
24
|
+
|
|
25
|
+
## Summary
|
|
26
|
+
- Short bullets describing the main changes
|
|
27
|
+
|
|
28
|
+
## Why
|
|
29
|
+
- Why this PR exists
|
|
30
|
+
|
|
31
|
+
## Testing
|
|
32
|
+
- Mention visible testing evidence from the diff if any
|
|
33
|
+
- If no testing evidence is visible, say "Not specified in diff"
|
|
34
|
+
|
|
35
|
+
## Risks
|
|
36
|
+
- Briefly describe rollout, compatibility, or review risks
|
|
37
|
+
|
|
38
|
+
## Screenshots
|
|
39
|
+
- If the diff suggests UI work, include "Screenshots: Needed"
|
|
40
|
+
- Otherwise include "Screenshots: Not needed"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Review this change for refactoring opportunities.
|
|
2
|
+
|
|
3
|
+
Commit Message:
|
|
4
|
+
{{commit_message}}
|
|
5
|
+
|
|
6
|
+
Files Changed:
|
|
7
|
+
{{files_changed}}
|
|
8
|
+
|
|
9
|
+
Stats:
|
|
10
|
+
{{stats}}
|
|
11
|
+
|
|
12
|
+
Change Hints:
|
|
13
|
+
{{change_hints}}
|
|
14
|
+
|
|
15
|
+
Diff:
|
|
16
|
+
{{diff}}
|
|
17
|
+
|
|
18
|
+
Return:
|
|
19
|
+
|
|
20
|
+
1. Refactor Opportunities:
|
|
21
|
+
- List concrete refactors suggested by the code shown
|
|
22
|
+
- Focus on duplication, naming, cohesion, dead code, control flow, error handling, and API clarity
|
|
23
|
+
- If there are no worthwhile refactors, say so explicitly
|
|
24
|
+
|
|
25
|
+
2. Why These Matter:
|
|
26
|
+
- Explain the maintenance or correctness benefits of the top opportunities
|
|
27
|
+
|
|
28
|
+
3. Safe Next Steps:
|
|
29
|
+
- Suggest a small, practical follow-up plan that avoids mixing refactors with risky behavior changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Explain the contents of this Git stash entry.
|
|
2
|
+
|
|
3
|
+
Context:
|
|
4
|
+
- This stash may include staged work, unstaged work, or both.
|
|
5
|
+
- Focus on what work is preserved here, why it may have been stashed, and what to watch for before applying it.
|
|
6
|
+
|
|
7
|
+
Stash Message:
|
|
8
|
+
{{commit_message}}
|
|
9
|
+
|
|
10
|
+
Files Changed:
|
|
11
|
+
{{files_changed}}
|
|
12
|
+
|
|
13
|
+
Stats:
|
|
14
|
+
{{stats}}
|
|
15
|
+
|
|
16
|
+
Change Hints:
|
|
17
|
+
{{change_hints}}
|
|
18
|
+
|
|
19
|
+
Diff:
|
|
20
|
+
{{diff}}
|
|
21
|
+
|
|
22
|
+
Return:
|
|
23
|
+
|
|
24
|
+
1. Summary:
|
|
25
|
+
- Explain what work is stored in the stash
|
|
26
|
+
|
|
27
|
+
2. Likely Intent:
|
|
28
|
+
- Explain why a developer might have stashed these changes
|
|
29
|
+
|
|
30
|
+
3. Key Changes:
|
|
31
|
+
- Summarize the important code or file-level changes
|
|
32
|
+
|
|
33
|
+
4. Reapply Notes:
|
|
34
|
+
- Mention any cautions, missing context, or likely conflicts to watch for when applying the stash
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Suggest what tests should be added or updated for this change.
|
|
2
|
+
|
|
3
|
+
Commit Message:
|
|
4
|
+
{{commit_message}}
|
|
5
|
+
|
|
6
|
+
Files Changed:
|
|
7
|
+
{{files_changed}}
|
|
8
|
+
|
|
9
|
+
Stats:
|
|
10
|
+
{{stats}}
|
|
11
|
+
|
|
12
|
+
Change Hints:
|
|
13
|
+
{{change_hints}}
|
|
14
|
+
|
|
15
|
+
Diff:
|
|
16
|
+
{{diff}}
|
|
17
|
+
|
|
18
|
+
Return:
|
|
19
|
+
|
|
20
|
+
1. Test Coverage Suggestions:
|
|
21
|
+
- List the highest-value tests to add or update
|
|
22
|
+
- Be specific about scenarios, assertions, and edge cases
|
|
23
|
+
- If existing coverage already looks sufficient, say so clearly
|
|
24
|
+
|
|
25
|
+
2. Risk Gaps:
|
|
26
|
+
- Call out the most important behaviors that could regress without tests
|
|
27
|
+
|
|
28
|
+
3. Suggested Test Plan:
|
|
29
|
+
- Organize the recommended tests by unit, integration, or end-to-end when appropriate
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
6
|
+
PACKAGE_JSON="${ROOT_DIR}/package.json"
|
|
7
|
+
VERSION="$(node -p "JSON.parse(require('node:fs').readFileSync(process.argv[1], 'utf8')).version" "${PACKAGE_JSON}")"
|
|
8
|
+
DESCRIPTION="$(node -p "JSON.parse(require('node:fs').readFileSync(process.argv[1], 'utf8')).description" "${PACKAGE_JSON}")"
|
|
9
|
+
PACKAGE_NAME="gitxplain"
|
|
10
|
+
ARCHITECTURE="${DEB_ARCHITECTURE:-all}"
|
|
11
|
+
MAINTAINER="${DEB_MAINTAINER:-Guruswarupa <opensource@local.invalid>}"
|
|
12
|
+
OUTPUT_DIR="${ROOT_DIR}/dist"
|
|
13
|
+
BUILD_ROOT="$(mktemp -d)"
|
|
14
|
+
PACKAGE_ROOT="${BUILD_ROOT}/${PACKAGE_NAME}_${VERSION}"
|
|
15
|
+
INSTALL_ROOT="${PACKAGE_ROOT}/usr/lib/${PACKAGE_NAME}"
|
|
16
|
+
CONTROL_DIR="${PACKAGE_ROOT}/DEBIAN"
|
|
17
|
+
DOC_DIR="${PACKAGE_ROOT}/usr/share/doc/${PACKAGE_NAME}"
|
|
18
|
+
DEB_FILE="${OUTPUT_DIR}/${PACKAGE_NAME}_${VERSION}_${ARCHITECTURE}.deb"
|
|
19
|
+
|
|
20
|
+
cleanup() {
|
|
21
|
+
rm -rf "${BUILD_ROOT}"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
trap cleanup EXIT
|
|
25
|
+
|
|
26
|
+
mkdir -p "${OUTPUT_DIR}" "${INSTALL_ROOT}" "${CONTROL_DIR}" "${DOC_DIR}" "${PACKAGE_ROOT}/usr/bin"
|
|
27
|
+
|
|
28
|
+
cp -a \
|
|
29
|
+
"${ROOT_DIR}/cli" \
|
|
30
|
+
"${ROOT_DIR}/prompts" \
|
|
31
|
+
"${ROOT_DIR}/package.json" \
|
|
32
|
+
"${ROOT_DIR}/README.md" \
|
|
33
|
+
"${INSTALL_ROOT}/"
|
|
34
|
+
|
|
35
|
+
find "${PACKAGE_ROOT}" -type d -exec chmod 755 {} +
|
|
36
|
+
find "${PACKAGE_ROOT}" -type f -exec chmod 644 {} +
|
|
37
|
+
chmod 755 "${INSTALL_ROOT}/cli/index.js"
|
|
38
|
+
ln -s "../lib/${PACKAGE_NAME}/cli/index.js" "${PACKAGE_ROOT}/usr/bin/gitxplain"
|
|
39
|
+
ln -s "../lib/${PACKAGE_NAME}/cli/index.js" "${PACKAGE_ROOT}/usr/bin/gitxplore"
|
|
40
|
+
|
|
41
|
+
cat > "${CONTROL_DIR}/control" <<EOF
|
|
42
|
+
Package: ${PACKAGE_NAME}
|
|
43
|
+
Version: ${VERSION}
|
|
44
|
+
Section: utils
|
|
45
|
+
Priority: optional
|
|
46
|
+
Architecture: ${ARCHITECTURE}
|
|
47
|
+
Maintainer: ${MAINTAINER}
|
|
48
|
+
Depends: nodejs (>= 18)
|
|
49
|
+
Homepage: https://github.com/guruswarupa/gitxplain
|
|
50
|
+
Description: ${DESCRIPTION}
|
|
51
|
+
AI-powered Git commit explainer CLI distributed as a Debian package.
|
|
52
|
+
EOF
|
|
53
|
+
|
|
54
|
+
cat > "${DOC_DIR}/copyright" <<EOF
|
|
55
|
+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|
56
|
+
Upstream-Name: gitxplain
|
|
57
|
+
Source: https://github.com/guruswarupa/gitxplain
|
|
58
|
+
|
|
59
|
+
Files: *
|
|
60
|
+
License: MIT
|
|
61
|
+
EOF
|
|
62
|
+
|
|
63
|
+
dpkg-deb --root-owner-group --build "${PACKAGE_ROOT}" "${DEB_FILE}" >/dev/null
|
|
64
|
+
echo "${DEB_FILE}"
|
package/IMPLEMENTATION.md
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
# GitXplain Enhancement - Implementation Summary
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Successfully implemented two major new features for gitxplain:
|
|
5
|
-
1. **GitHub Connection** (`--connect-github`) - Connect GitHub account with Personal Access Token
|
|
6
|
-
2. **Interactive Chat Interface** (`--boot`) - Start a chat session with repository context
|
|
7
|
-
|
|
8
|
-
## New Features
|
|
9
|
-
|
|
10
|
-
### 1. GitHub Connection Feature (`--connect-github`)
|
|
11
|
-
|
|
12
|
-
**Command:**
|
|
13
|
-
```bash
|
|
14
|
-
gitxplain --connect-github
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
**Functionality:**
|
|
18
|
-
- Prompts user for GitHub Personal Access Token (PAT)
|
|
19
|
-
- Saves connection securely to `~/.gitxplain/git-connection.json`
|
|
20
|
-
- Displays user's git configuration (name and email)
|
|
21
|
-
- Shows success message upon completion
|
|
22
|
-
- Required before using `--boot` feature
|
|
23
|
-
|
|
24
|
-
**Files Created:**
|
|
25
|
-
- `cli/services/gitConnectionService.js` - Handles connection storage and retrieval
|
|
26
|
-
|
|
27
|
-
**Key Functions:**
|
|
28
|
-
- `saveGitConnection(token, provider)` - Saves PAT locally
|
|
29
|
-
- `loadGitConnection()` - Retrieves saved connection
|
|
30
|
-
- `isGitConnected()` - Checks if connection exists
|
|
31
|
-
- `getGitUserInfo()` - Gets git user name/email
|
|
32
|
-
|
|
33
|
-
### 2. Interactive Chat Interface (`--boot`)
|
|
34
|
-
|
|
35
|
-
**Command:**
|
|
36
|
-
```bash
|
|
37
|
-
gitxplain --boot
|
|
38
|
-
gitxplain --boot --provider groq --model llama-3.3-70b-versatile
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**Functionality:**
|
|
42
|
-
- Requires prior git connection (`gitxplain --connect-github`)
|
|
43
|
-
- Initializes repository context (commits, branches, status)
|
|
44
|
-
- Launches interactive readline interface
|
|
45
|
-
- Maintains conversation history with LLM
|
|
46
|
-
- Supports all LLM providers (OpenAI, Groq, OpenRouter, Gemini, Ollama, Chutes)
|
|
47
|
-
|
|
48
|
-
**Files Created:**
|
|
49
|
-
- `cli/services/chatService.js` - Chat interface implementation
|
|
50
|
-
|
|
51
|
-
**Key Features:**
|
|
52
|
-
- Repository Context Awareness
|
|
53
|
-
- Last 20 commits with abbreviated hash and message
|
|
54
|
-
- All git branches (local and remote)
|
|
55
|
-
- Current working directory status
|
|
56
|
-
|
|
57
|
-
- Chat Commands:
|
|
58
|
-
- Type normally to ask questions about the code/commits
|
|
59
|
-
- `clear` - Reset conversation history
|
|
60
|
-
- `exit` - Close chat session
|
|
61
|
-
|
|
62
|
-
- Multi-Provider Support:
|
|
63
|
-
- OpenAI Compatible providers: OpenAI, Groq, OpenRouter, Chutes
|
|
64
|
-
- Specialized providers: Gemini (with custom formatting)
|
|
65
|
-
- Local providers: Ollama
|
|
66
|
-
|
|
67
|
-
**Key Classes:**
|
|
68
|
-
- `ChatService` - Main chat interface class
|
|
69
|
-
- `constructor(cwd, providerOverride, modelOverride)` - Initialize service
|
|
70
|
-
- `initializeRepoContext()` - Load repository information
|
|
71
|
-
- `buildSystemPrompt()` - Create context-aware system prompt
|
|
72
|
-
- `sendMessage(userMessage)` - Handle user input
|
|
73
|
-
- `startInteractiveChat()` - Main interactive loop
|
|
74
|
-
|
|
75
|
-
### 3. Updated CLI (`cli/index.js`)
|
|
76
|
-
|
|
77
|
-
**New Flags:**
|
|
78
|
-
- `--connect-github` - Initialize GitHub connection
|
|
79
|
-
- `--boot` - Start interactive chat session
|
|
80
|
-
|
|
81
|
-
**Updated Features:**
|
|
82
|
-
- `parseArgs()` - Now detects `connectGitHub` and `boot` flags
|
|
83
|
-
- `handleConnectGit()` - Manages connection workflow
|
|
84
|
-
- `handleBoot()` - Manages chat initialization
|
|
85
|
-
- `printHelp()` - Updated documentation
|
|
86
|
-
|
|
87
|
-
**Error Handling:**
|
|
88
|
-
- Checks for git repository existence
|
|
89
|
-
- Validates connection before allowing `--boot`
|
|
90
|
-
- Graceful error messages for missing PAT or connection
|
|
91
|
-
|
|
92
|
-
## Updated Files
|
|
93
|
-
|
|
94
|
-
### `cli/services/aiService.js`
|
|
95
|
-
- Exported `getProviderConfig()` function (moved from private)
|
|
96
|
-
- Exported `validateProviderConfig()` function (moved from private)
|
|
97
|
-
- These are now used by `chatService.js`
|
|
98
|
-
|
|
99
|
-
### `package.json`
|
|
100
|
-
- Updated lint script to include new service files
|
|
101
|
-
- `gitConnectionService.js`
|
|
102
|
-
- `chatService.js`
|
|
103
|
-
|
|
104
|
-
### `README.md`
|
|
105
|
-
- Added new features documentation
|
|
106
|
-
- Added usage examples for `--connect-github` and `--boot`
|
|
107
|
-
- Added section explaining chat commands
|
|
108
|
-
|
|
109
|
-
## Connection Storage
|
|
110
|
-
|
|
111
|
-
**Location:** `~/.gitxplain/git-connection.json`
|
|
112
|
-
|
|
113
|
-
**Format:**
|
|
114
|
-
```json
|
|
115
|
-
{
|
|
116
|
-
"token": "github_pat_xxx",
|
|
117
|
-
"provider": "github",
|
|
118
|
-
"connectedAt": "2026-04-08T09:45:18.238Z"
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**Security Notes:**
|
|
123
|
-
- Token stored locally in user's home directory
|
|
124
|
-
- Not included in version control (added to `.gitignore`)
|
|
125
|
-
- Can be manually deleted to disconnect
|
|
126
|
-
|
|
127
|
-
## Testing
|
|
128
|
-
|
|
129
|
-
✅ All features tested and working:
|
|
130
|
-
1. `--connect-github` successfully saves PAT
|
|
131
|
-
2. Connection file created at correct location
|
|
132
|
-
3. `--boot` checks for existing connection
|
|
133
|
-
4. Help text updated with new commands
|
|
134
|
-
5. Syntax validation passes for all files
|
|
135
|
-
|
|
136
|
-
## Usage Examples
|
|
137
|
-
|
|
138
|
-
### Connect to GitHub
|
|
139
|
-
```bash
|
|
140
|
-
gitxplain --connect-github
|
|
141
|
-
# Enter your PAT when prompted
|
|
142
|
-
# Output: Git Connected Successfully
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Start Interactive Chat with Default Provider
|
|
146
|
-
```bash
|
|
147
|
-
gitxplain --boot
|
|
148
|
-
# Opens chat interface with repository context
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Start Chat with Specific Provider
|
|
152
|
-
```bash
|
|
153
|
-
gitxplain --boot --provider groq --model llama-3.3-70b-versatile
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Chat Commands
|
|
157
|
-
```
|
|
158
|
-
You: What commits were made recently?
|
|
159
|
-
[Assistant responds about recent commits]
|
|
160
|
-
|
|
161
|
-
You: Explain the last change
|
|
162
|
-
[Assistant explains based on repo context]
|
|
163
|
-
|
|
164
|
-
You: clear
|
|
165
|
-
[Conversation history cleared]
|
|
166
|
-
|
|
167
|
-
You: exit
|
|
168
|
-
[Chat session ends]
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Architecture
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
CLI (index.js)
|
|
175
|
-
├── parseArgs() → detects --connect-github, --boot
|
|
176
|
-
├── handleConnectGit()
|
|
177
|
-
│ └── gitConnectionService.js
|
|
178
|
-
│ ├── saveGitConnection()
|
|
179
|
-
│ └── getGitUserInfo()
|
|
180
|
-
└── handleBoot()
|
|
181
|
-
└── chatService.js
|
|
182
|
-
├── ChatService class
|
|
183
|
-
├── initializeRepoContext()
|
|
184
|
-
├── sendMessage()
|
|
185
|
-
└── startInteractiveChat()
|
|
186
|
-
└── aiService.js
|
|
187
|
-
├── getProviderConfig()
|
|
188
|
-
└── validateProviderConfig()
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## Backward Compatibility
|
|
192
|
-
|
|
193
|
-
✅ All existing features remain fully functional:
|
|
194
|
-
- Commit analysis (`gitxplain <commit-id>`)
|
|
195
|
-
- All analysis modes (--summary, --issues, --fix, --impact, --full)
|
|
196
|
-
- Provider override (--provider, --model)
|
|
197
|
-
- Output formatting (--json)
|
|
198
|
-
- Help command
|
|
199
|
-
|
|
200
|
-
## Next Steps (Optional Enhancements)
|
|
201
|
-
|
|
202
|
-
1. Add token validation against GitHub API
|
|
203
|
-
2. Add token expiration checking
|
|
204
|
-
3. Add support for other git platforms (GitLab, Bitbucket)
|
|
205
|
-
4. Add option to save chat history
|
|
206
|
-
5. Add syntax highlighting in chat output
|
|
207
|
-
6. Add keyboard shortcuts for chat commands
|
|
208
|
-
|
|
209
|
-
## Files Modified/Created
|
|
210
|
-
|
|
211
|
-
### Created:
|
|
212
|
-
- `cli/services/gitConnectionService.js` (134 lines)
|
|
213
|
-
- `cli/services/chatService.js` (216 lines)
|
|
214
|
-
|
|
215
|
-
### Modified:
|
|
216
|
-
- `cli/index.js` - Added new features, updated help, added handlers
|
|
217
|
-
- `cli/services/aiService.js` - Exported previously private functions
|
|
218
|
-
- `package.json` - Updated lint script
|
|
219
|
-
- `README.md` - Updated documentation
|
|
220
|
-
|
|
221
|
-
### Unchanged but Supporting:
|
|
222
|
-
- `cli/services/gitService.js` - Git integration
|
|
223
|
-
- `cli/services/outputFormatter.js` - Output formatting
|
|
224
|
-
- `cli/services/promptService.js` - Prompt templates
|
|
225
|
-
- Prompts directory - All prompt templates
|