gitxplain 0.1.8 → 0.1.9
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 +190 -4
- package/cli/index.js +430 -117
- 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 +33 -27
- package/cli/services/outputFormatter.js +23 -73
- package/cli/services/pipelineService.js +112 -0
- package/cli/services/promptService.js +8 -1
- package/cli/services/splitService.js +1 -21
- package/cli/services/usageService.js +158 -0
- package/package.json +2 -2
- 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/IMPLEMENTATION.md +0 -225
- package/cli/services/chatService.js +0 -683
- package/cli/services/gitConnectionService.js +0 -267
|
@@ -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
|
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
|