@g-abhishek/gitx 0.1.2 → 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.
Files changed (165) hide show
  1. package/README.md +386 -3
  2. package/dist/ai/claudeAi.d.ts +35 -0
  3. package/dist/ai/claudeAi.d.ts.map +1 -0
  4. package/dist/ai/claudeAi.js +396 -0
  5. package/dist/ai/claudeAi.js.map +1 -0
  6. package/dist/ai/claudeCliAi.d.ts +27 -0
  7. package/dist/ai/claudeCliAi.d.ts.map +1 -0
  8. package/dist/ai/claudeCliAi.js +312 -0
  9. package/dist/ai/claudeCliAi.js.map +1 -0
  10. package/dist/ai/localClaudeAi.d.ts +2 -0
  11. package/dist/ai/localClaudeAi.d.ts.map +1 -0
  12. package/dist/ai/localClaudeAi.js +4 -0
  13. package/dist/ai/localClaudeAi.js.map +1 -0
  14. package/dist/ai/mockAi.d.ts +8 -1
  15. package/dist/ai/mockAi.d.ts.map +1 -1
  16. package/dist/ai/mockAi.js +57 -0
  17. package/dist/ai/mockAi.js.map +1 -1
  18. package/dist/ai/openAiAi.d.ts +33 -0
  19. package/dist/ai/openAiAi.d.ts.map +1 -0
  20. package/dist/ai/openAiAi.js +388 -0
  21. package/dist/ai/openAiAi.js.map +1 -0
  22. package/dist/ai/reviewHelpers.d.ts +66 -0
  23. package/dist/ai/reviewHelpers.d.ts.map +1 -0
  24. package/dist/ai/reviewHelpers.js +574 -0
  25. package/dist/ai/reviewHelpers.js.map +1 -0
  26. package/dist/ai/types.d.ts +247 -0
  27. package/dist/ai/types.d.ts.map +1 -1
  28. package/dist/ai/types.js.map +1 -1
  29. package/dist/cli/commands/ask.d.ts +27 -0
  30. package/dist/cli/commands/ask.d.ts.map +1 -0
  31. package/dist/cli/commands/ask.js +230 -0
  32. package/dist/cli/commands/ask.js.map +1 -0
  33. package/dist/cli/commands/commit.d.ts +16 -0
  34. package/dist/cli/commands/commit.d.ts.map +1 -0
  35. package/dist/cli/commands/commit.js +163 -0
  36. package/dist/cli/commands/commit.js.map +1 -0
  37. package/dist/cli/commands/config.d.ts +4 -0
  38. package/dist/cli/commands/config.d.ts.map +1 -0
  39. package/dist/cli/commands/config.js +666 -0
  40. package/dist/cli/commands/config.js.map +1 -0
  41. package/dist/cli/commands/implement.d.ts.map +1 -1
  42. package/dist/cli/commands/implement.js +149 -31
  43. package/dist/cli/commands/implement.js.map +1 -1
  44. package/dist/cli/commands/init.d.ts +4 -0
  45. package/dist/cli/commands/init.d.ts.map +1 -1
  46. package/dist/cli/commands/init.js +7 -69
  47. package/dist/cli/commands/init.js.map +1 -1
  48. package/dist/cli/commands/port.d.ts +32 -0
  49. package/dist/cli/commands/port.d.ts.map +1 -0
  50. package/dist/cli/commands/port.js +554 -0
  51. package/dist/cli/commands/port.js.map +1 -0
  52. package/dist/cli/commands/pr/close.d.ts +15 -0
  53. package/dist/cli/commands/pr/close.d.ts.map +1 -0
  54. package/dist/cli/commands/pr/close.js +71 -0
  55. package/dist/cli/commands/pr/close.js.map +1 -0
  56. package/dist/cli/commands/pr/create.d.ts +17 -0
  57. package/dist/cli/commands/pr/create.d.ts.map +1 -1
  58. package/dist/cli/commands/pr/create.js +208 -7
  59. package/dist/cli/commands/pr/create.js.map +1 -1
  60. package/dist/cli/commands/pr/fixComments.d.ts +5 -2
  61. package/dist/cli/commands/pr/fixComments.d.ts.map +1 -1
  62. package/dist/cli/commands/pr/fixComments.js +5 -13
  63. package/dist/cli/commands/pr/fixComments.js.map +1 -1
  64. package/dist/cli/commands/pr/index.d.ts.map +1 -1
  65. package/dist/cli/commands/pr/index.js +6 -2
  66. package/dist/cli/commands/pr/index.js.map +1 -1
  67. package/dist/cli/commands/pr/list.d.ts.map +1 -1
  68. package/dist/cli/commands/pr/list.js +24 -4
  69. package/dist/cli/commands/pr/list.js.map +1 -1
  70. package/dist/cli/commands/pr/merge.d.ts +23 -0
  71. package/dist/cli/commands/pr/merge.d.ts.map +1 -0
  72. package/dist/cli/commands/pr/merge.js +191 -0
  73. package/dist/cli/commands/pr/merge.js.map +1 -0
  74. package/dist/cli/commands/pr/resolve.d.ts +3 -0
  75. package/dist/cli/commands/pr/resolve.d.ts.map +1 -0
  76. package/dist/cli/commands/pr/resolve.js +92 -0
  77. package/dist/cli/commands/pr/resolve.js.map +1 -0
  78. package/dist/cli/commands/pr/review.d.ts.map +1 -1
  79. package/dist/cli/commands/pr/review.js +121 -6
  80. package/dist/cli/commands/pr/review.js.map +1 -1
  81. package/dist/cli/commands/push.d.ts +16 -0
  82. package/dist/cli/commands/push.d.ts.map +1 -0
  83. package/dist/cli/commands/push.js +166 -0
  84. package/dist/cli/commands/push.js.map +1 -0
  85. package/dist/cli/commands/sync.d.ts +24 -0
  86. package/dist/cli/commands/sync.d.ts.map +1 -0
  87. package/dist/cli/commands/sync.js +414 -0
  88. package/dist/cli/commands/sync.js.map +1 -0
  89. package/dist/cli/index.d.ts.map +1 -1
  90. package/dist/cli/index.js +34 -6
  91. package/dist/cli/index.js.map +1 -1
  92. package/dist/config/config.d.ts +20 -3
  93. package/dist/config/config.d.ts.map +1 -1
  94. package/dist/config/config.js +98 -45
  95. package/dist/config/config.js.map +1 -1
  96. package/dist/config/schema.d.ts.map +1 -1
  97. package/dist/config/schema.js +61 -6
  98. package/dist/config/schema.js.map +1 -1
  99. package/dist/core/context.d.ts +6 -0
  100. package/dist/core/context.d.ts.map +1 -1
  101. package/dist/core/context.js.map +1 -1
  102. package/dist/core/gitx.d.ts +43 -0
  103. package/dist/core/gitx.d.ts.map +1 -1
  104. package/dist/core/gitx.js +187 -20
  105. package/dist/core/gitx.js.map +1 -1
  106. package/dist/index.d.ts +1 -5
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +4 -1
  109. package/dist/index.js.map +1 -1
  110. package/dist/providers/azure.d.ts +26 -0
  111. package/dist/providers/azure.d.ts.map +1 -0
  112. package/dist/providers/azure.js +256 -0
  113. package/dist/providers/azure.js.map +1 -0
  114. package/dist/providers/base.d.ts +104 -0
  115. package/dist/providers/base.d.ts.map +1 -0
  116. package/dist/providers/base.js +5 -0
  117. package/dist/providers/base.js.map +1 -0
  118. package/dist/providers/factory.d.ts +8 -0
  119. package/dist/providers/factory.d.ts.map +1 -0
  120. package/dist/providers/factory.js +25 -0
  121. package/dist/providers/factory.js.map +1 -0
  122. package/dist/providers/github.d.ts +19 -0
  123. package/dist/providers/github.d.ts.map +1 -0
  124. package/dist/providers/github.js +291 -0
  125. package/dist/providers/github.js.map +1 -0
  126. package/dist/providers/gitlab.d.ts +19 -0
  127. package/dist/providers/gitlab.d.ts.map +1 -0
  128. package/dist/providers/gitlab.js +186 -0
  129. package/dist/providers/gitlab.js.map +1 -0
  130. package/dist/types/config.d.ts +50 -7
  131. package/dist/types/config.d.ts.map +1 -1
  132. package/dist/types/config.js.map +1 -1
  133. package/dist/utils/azureAuth.d.ts +51 -0
  134. package/dist/utils/azureAuth.d.ts.map +1 -0
  135. package/dist/utils/azureAuth.js +172 -0
  136. package/dist/utils/azureAuth.js.map +1 -0
  137. package/dist/utils/git.d.ts +19 -0
  138. package/dist/utils/git.d.ts.map +1 -1
  139. package/dist/utils/git.js +45 -8
  140. package/dist/utils/git.js.map +1 -1
  141. package/dist/utils/gitOps.d.ts +125 -0
  142. package/dist/utils/gitOps.d.ts.map +1 -0
  143. package/dist/utils/gitOps.js +396 -0
  144. package/dist/utils/gitOps.js.map +1 -0
  145. package/dist/utils/lockFile.d.ts +13 -0
  146. package/dist/utils/lockFile.d.ts.map +1 -0
  147. package/dist/utils/lockFile.js +54 -0
  148. package/dist/utils/lockFile.js.map +1 -0
  149. package/dist/utils/retry.d.ts +10 -0
  150. package/dist/utils/retry.d.ts.map +1 -0
  151. package/dist/utils/retry.js +31 -0
  152. package/dist/utils/retry.js.map +1 -0
  153. package/dist/workflows/implement.d.ts +41 -0
  154. package/dist/workflows/implement.d.ts.map +1 -0
  155. package/dist/workflows/implement.js +219 -0
  156. package/dist/workflows/implement.js.map +1 -0
  157. package/dist/workflows/pr.d.ts +41 -0
  158. package/dist/workflows/pr.d.ts.map +1 -0
  159. package/dist/workflows/pr.js +291 -0
  160. package/dist/workflows/pr.js.map +1 -0
  161. package/dist/workflows/prAddress.d.ts +55 -0
  162. package/dist/workflows/prAddress.d.ts.map +1 -0
  163. package/dist/workflows/prAddress.js +349 -0
  164. package/dist/workflows/prAddress.js.map +1 -0
  165. package/package.json +1 -1
package/README.md CHANGED
@@ -1,12 +1,395 @@
1
1
  # gitx
2
2
 
3
- AI-powered Git workflow automation CLI and SDK (WIP).
3
+ **AI-powered Git workflow automation CLI and SDK.**
4
4
 
5
- ## Getting started
5
+ gitx wraps your everyday git operations with AI to generate commit messages, write PR descriptions, review code, resolve merge conflicts, implement tasks from a plain-English prompt, and answer questions about your repo — all from a single CLI.
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ - [Features](#features)
12
+ - [Installation](#installation)
13
+ - [Configuration](#configuration)
14
+ - [Commands](#commands)
15
+ - [gitx ask](#gitx-ask)
16
+ - [gitx commit](#gitx-commit)
17
+ - [gitx push](#gitx-push)
18
+ - [gitx sync](#gitx-sync)
19
+ - [gitx implement](#gitx-implement)
20
+ - [gitx pr create](#gitx-pr-create)
21
+ - [gitx pr review](#gitx-pr-review)
22
+ - [gitx pr resolve](#gitx-pr-resolve)
23
+ - [gitx pr merge](#gitx-pr-merge)
24
+ - [gitx pr list](#gitx-pr-list)
25
+ - [gitx pr close](#gitx-pr-close)
26
+ - [gitx config](#gitx-config)
27
+ - [Supported Providers](#supported-providers)
28
+ - [Environment Variables](#environment-variables)
29
+
30
+ ---
31
+
32
+ ## Features
33
+
34
+ | Feature | What it does |
35
+ |---------|--------------|
36
+ | **AI commit messages** | Generates conventional-commit messages from your staged diff |
37
+ | **AI PR descriptions** | Writes PR title + body from your branch commits and diff |
38
+ | **AI code review** | Senior-dev quality review with inline comments posted to GitHub/GitLab/Azure (`gitx pr review`) |
39
+ | **AI comment resolve** | Reads unresolved review comments, fixes them in code, commits and pushes (`gitx pr resolve`) |
40
+ | **AI conflict resolution** | Tries to auto-resolve merge/rebase conflicts; prompts when unsure |
41
+ | **AI task implementation** | Takes a plain-English task, plans and applies diffs, commits, pushes, opens PR |
42
+ | **gitx ask** | Ask anything about your repo — get answers grounded in live git context |
43
+
44
+ ---
45
+
46
+ ## Installation
6
47
 
7
48
  ```bash
49
+ # Clone and build
50
+ git clone https://github.com/g-abhishek/gitx.git
51
+ cd gitx
8
52
  npm install
9
53
  npm run build
10
- node dist/bin.js --help
54
+
55
+ # Link globally so `gitx` is available everywhere
56
+ npm link
57
+ ```
58
+
59
+ **Requirements:** Node.js ≥ 18
60
+
61
+ ---
62
+
63
+ ## Configuration
64
+
65
+ Run the interactive setup wizard on first use:
66
+
67
+ ```bash
68
+ gitx init
69
+ # or equivalently:
70
+ gitx config setup
71
+ ```
72
+
73
+ The wizard will ask you to configure:
74
+
75
+ 1. **Git provider** — GitHub, GitLab, or Azure DevOps
76
+ 2. **AI provider** — Anthropic Claude (API key), OpenAI (API key), or local Claude CLI (no key needed)
77
+
78
+ Config is stored in `~/.config/gitx/config.json` (or the platform-appropriate XDG path).
79
+
80
+ **Quick config with env vars (no wizard needed):**
81
+
82
+ ```bash
83
+ export ANTHROPIC_API_KEY=sk-ant-… # enables Claude automatically
84
+ export OPENAI_API_KEY=sk-… # enables OpenAI automatically
85
+ ```
86
+
87
+ ### Azure DevOps authentication
88
+
89
+ Azure DevOps supports two authentication methods:
90
+
91
+ | Method | When to use |
92
+ |--------|-------------|
93
+ | **GCM (recommended)** | Your company uses Git Credential Manager + OAuth (blocks PAT tokens) |
94
+ | **PAT** | Personal Access Token — classic approach, works everywhere |
95
+
96
+ **GCM setup (one time):**
97
+
98
+ ```bash
99
+ # 1. Configure git to use OAuth for Azure DevOps
100
+ git config --global credential.azreposCredentialType oauth
101
+ git config --global credential.https://dev.azure.com.useHttpPath true
102
+
103
+ # 2. Run gitx setup — choose "Azure DevOps" → "GCM"
104
+ gitx config set azure
105
+ # gitx verifies your GCM setup and saves authMethod: "gcm" — no token stored
106
+ ```
107
+
108
+ With GCM configured, gitx calls `git credential fill` at runtime to obtain a short-lived OAuth token. GCM handles browser login (once) and silent token refresh automatically.
109
+
110
+ ---
111
+
112
+ ## Commands
113
+
114
+ ### gitx ask
115
+
116
+ Acts as a smart support assistant that can answer three categories of question — all in one command.
117
+
118
+ ```bash
119
+ gitx ask "<question>"
120
+ gitx ask "<question>" --pr # also fetch open PRs for context
121
+ ```
122
+
123
+ **1. Setup & diagnostic questions** — answered from your live gitx config (no fabrication):
124
+
125
+ ```bash
126
+ gitx ask "is my AI provider set up?"
127
+ gitx ask "which AI model am I using?"
128
+ gitx ask "do I have a GitHub token configured?"
129
+ gitx ask "why isn't gitx working?"
130
+ ```
131
+
132
+ **2. Repo state questions** — answered from live git data:
133
+
134
+ ```bash
135
+ gitx ask "what did I last commit?"
136
+ gitx ask "do I have any unstaged changes?"
137
+ gitx ask "show me all open PRs" --pr
138
+ gitx ask "do I have any stashed changes?"
139
+ ```
140
+
141
+ **3. How-to questions** — answered from the built-in command reference:
142
+
143
+ ```bash
144
+ gitx ask "how do I sync my branch with main?"
145
+ gitx ask "how do I undo my last commit without losing changes?"
146
+ gitx ask "what command creates a PR?"
147
+ gitx ask "how do I implement a task with AI?"
148
+ ```
149
+
150
+ **Sources the AI draws from:**
151
+
152
+ - **Live gitx config** — which AI provider is active, whether keys are set, which git providers have tokens (keys are never exposed, only their presence/absence)
153
+ - **Live git state** — current branch, last 10 commits, working-tree status, stash list
154
+ - **Open PRs** — fetched from the provider API when `--pr` is passed or the question mentions "PR"
155
+ - **Built-in command reference** — the full gitx command table is embedded in every prompt
156
+
157
+ ---
158
+
159
+ ### gitx commit
160
+
161
+ Stage all changes, AI-generate a conventional-commit message from the diff, preview it, and commit.
162
+
163
+ ```bash
164
+ gitx commit # stage → AI message → confirm → commit
165
+ gitx commit -m "feat: …" # skip AI, use your own message
166
+ gitx commit --push # commit then push to origin
167
+ gitx commit --dry-run # preview the AI message without committing
168
+ ```
169
+
170
+ The AI always receives a `git diff --stat` file summary alongside the diff, so it sees every changed file even when the diff is large and gets truncated.
171
+
172
+ ---
173
+
174
+ ### gitx push
175
+
176
+ Stage → AI-commit → push in one command.
177
+
178
+ ```bash
179
+ gitx push
180
+ gitx push -b feature/my-branch # push to a specific branch name
181
+ gitx push --staged # commit only already-staged files (skip git add -A)
182
+ gitx push --dry-run # preview without pushing
183
+ ```
184
+
185
+ Use `--staged` when you've manually staged a subset of changes with `git add` and want the AI commit message to reflect only those changes.
186
+
187
+ ---
188
+
189
+ ### gitx sync
190
+
191
+ Sync your current branch with its base branch. Auto-detects the base branch, fetches from origin, then merges or rebases.
192
+
193
+ ```bash
194
+ gitx sync # auto-detect base, merge (default)
195
+ gitx sync --strategy rebase # rebase instead of merge
196
+ gitx sync --base develop # explicitly set the base branch
197
+ gitx sync --continue # resume after manually resolving conflicts
198
+ gitx sync --abort # cancel an in-progress operation
199
+ ```
200
+
201
+ **AI conflict resolution:** When a merge/rebase conflict is detected, gitx asks the AI to resolve it. High-confidence resolutions are applied automatically; low-confidence ones are shown to you for confirmation.
202
+
203
+ **Pre-sync PR comment check:** If your branch has an open PR with unresolved review comments, gitx will ask whether to address them before syncing. Choosing "Resolve comments first" runs the address workflow, commits the fixes, then the sync rebase/merge picks everything up in a single push.
204
+
205
+ ---
206
+
207
+ ### gitx port
208
+
209
+ Port commits from your current branch onto one or more other branches — the solution to "my lead wants this change on two other branches too."
210
+
211
+ gitx uses `git cherry` (patch-ID comparison) to detect which commits are already ported, so re-running is always safe and incremental.
212
+
213
+ ```bash
214
+ # From your feature branch:
215
+ gitx port release/v2 # port to one branch
216
+ gitx port release/v2 hotfix/v1 # port to multiple at once
217
+ gitx port release/v2 --base develop # override base branch detection
218
+ gitx port release/v2 --no-pr # push only, create PRs manually
219
+ gitx port release/v2 --draft # create draft PRs
220
+
221
+ # After adding more commits — only NEW commits will be ported:
222
+ gitx port release/v2 # incremental: skips already-ported commits
223
+
224
+ # Conflict resolution:
225
+ gitx port --continue # after manually fixing conflicts
226
+ gitx port --abort # abandon a stuck port
227
+ ```
228
+
229
+ **What it does per target branch:**
230
+ 1. Checks `origin/<target>` exists — errors clearly if not
231
+ 2. On first run: creates `port/<source>-to-<target>` and cherry-picks all commits
232
+ 3. On re-run: uses `git cherry` to find only NEW commits — skips already-ported ones
233
+ 4. Conflicts → AI attempts resolution; unresolvable ones pause for manual fix
234
+ 5. Pushes the port branch, checks for an existing open PR (updates it), or creates a new one with an AI-generated description
235
+
236
+ ---
237
+
238
+ ### gitx implement
239
+
240
+ Give the AI a task in plain English. It analyzes the repo, creates a plan, generates and applies diffs, commits, pushes, and opens a PR.
241
+
242
+ ```bash
243
+ gitx implement "add pagination to the users endpoint"
244
+ gitx implement "fix the null pointer on login" --mode guided
245
+ gitx implement "refactor auth module" --mode plan # plan only, no code changes
246
+ gitx implement "add unit tests for utils" --dry-run # preview plan, no commits
247
+ ```
248
+
249
+ **Autonomy modes:**
250
+
251
+ | Mode | Behaviour |
252
+ |------|-----------|
253
+ | `plan` | Analyze and generate a plan — no code changes |
254
+ | `guided` | Confirm after every AI step |
255
+ | `semi-auto` | Confirm once before execution begins |
256
+ | `auto` | Fully automatic end-to-end |
257
+
258
+ ---
259
+
260
+ ### gitx pr create
261
+
262
+ Stage any uncommitted changes, AI-generate a PR title and body from your branch commits and diff, and open the PR.
263
+
264
+ ```bash
265
+ gitx pr create
266
+ gitx pr create --title "feat: …" --body "…" # override AI-generated content
267
+ gitx pr create --draft # open as draft PR
268
+ gitx pr create --dry-run # preview without creating
11
269
  ```
12
270
 
271
+ ---
272
+
273
+ ### gitx pr review
274
+
275
+ Run a senior-developer quality AI review on an open PR and post the results as formal review comments (inline where supported).
276
+
277
+ ```bash
278
+ gitx pr review <number>
279
+ gitx pr review 42 --no-comment # show review locally, don't post to PR
280
+ gitx pr review 42 --inline # force inline comments (skip plain-comment fallback)
281
+ ```
282
+
283
+ The review covers: correctness, security, robustness, performance, breaking changes, best practices, test coverage, and documentation. After reviewing, run `gitx pr resolve <number>` to AI-fix the comments in your code.
284
+
285
+ ---
286
+
287
+ ### gitx pr resolve
288
+
289
+ Read all unresolved review comments on a PR, AI-generate targeted code fixes for each, and apply them.
290
+
291
+ ```bash
292
+ gitx pr resolve <number> # apply fixes, commit, and push
293
+ gitx pr resolve 42 --no-commit # apply fixes to working tree only — review before committing
294
+ gitx pr resolve 42 --no-push # apply and commit locally, skip push
295
+ gitx pr resolve 42 --dry-run # preview what would be fixed, nothing applied
296
+ ```
297
+
298
+ **Typical workflow:**
299
+ ```bash
300
+ gitx pr review 42 # AI reviews and posts inline comments to the PR
301
+ # ... read the comments, understand the feedback ...
302
+ gitx pr resolve 42 # AI fixes the comments in your code and pushes
303
+ ```
304
+
305
+ Use `--no-commit` when you want to inspect the AI-applied diffs with `git diff` before deciding to commit.
306
+
307
+ ---
308
+
309
+ ### gitx pr merge
310
+
311
+ Merge a pull request via the provider API.
312
+
313
+ ```bash
314
+ gitx pr merge <number>
315
+ gitx pr merge 42 --strategy rebase # rebase merge
316
+ gitx pr merge 42 --strategy merge # regular merge commit
317
+ gitx pr merge 42 --delete-branch # delete source branch after merge
318
+ gitx pr merge 42 --force # skip confirmation prompt
319
+ ```
320
+
321
+ Default strategy: `squash`.
322
+
323
+ ---
324
+
325
+ ### gitx pr list
326
+
327
+ List pull requests for the current repo.
328
+
329
+ ```bash
330
+ gitx pr list # open PRs (default)
331
+ gitx pr list --state closed
332
+ gitx pr list --state all
333
+ ```
334
+
335
+ ---
336
+
337
+ ### gitx pr close
338
+
339
+ Close (or abandon on Azure DevOps) a pull request.
340
+
341
+ ```bash
342
+ gitx pr close <number>
343
+ gitx pr close 42 --force # skip confirmation prompt
344
+ ```
345
+
346
+ ---
347
+
348
+ ### gitx config
349
+
350
+ Manage your gitx configuration.
351
+
352
+ ```bash
353
+ gitx config # run interactive setup wizard
354
+ gitx config setup # same as above
355
+ gitx config show # display current config (secrets redacted)
356
+ gitx config set github # configure GitHub token
357
+ gitx config set openai # configure OpenAI API key
358
+ gitx config set-default-ai claude # switch AI provider
359
+ gitx config set-default-branch main # set default base branch
360
+ ```
361
+
362
+ ---
363
+
364
+ ## Supported Providers
365
+
366
+ | Type | Supported |
367
+ |------|-----------|
368
+ | **Git hosts** | GitHub, GitLab, Azure DevOps |
369
+ | **Azure auth** | PAT (Personal Access Token), GCM OAuth (Git Credential Manager) |
370
+ | **AI backends** | Anthropic Claude (API), OpenAI GPT-4o, Local Claude CLI |
371
+
372
+ ---
373
+
374
+ ## Environment Variables
375
+
376
+ | Variable | Description |
377
+ |----------|-------------|
378
+ | `ANTHROPIC_API_KEY` | Anthropic API key — auto-selects Claude as the AI provider |
379
+ | `OPENAI_API_KEY` | OpenAI API key — auto-selects OpenAI as the AI provider |
380
+ | `GITX_AI_MODEL` | Override the AI model name (e.g. `claude-opus-4-5`, `gpt-4-turbo`) |
381
+ | `GITX_DEBUG=1` | Print full stack traces on errors |
382
+
383
+ AI provider priority when multiple are configured:
384
+ 1. `ANTHROPIC_API_KEY` env var → Claude
385
+ 2. `OPENAI_API_KEY` env var → OpenAI
386
+ 3. `defaultAiProvider` in config
387
+ 4. First configured provider entry with a key
388
+ 5. Auto-detected local `claude` CLI
389
+ 6. Mock fallback (warns user)
390
+
391
+ ---
392
+
393
+ ## License
394
+
395
+ MIT
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Claude AI integration via the Anthropic Messages API.
3
+ *
4
+ * Authentication: reads ANTHROPIC_API_KEY from the environment.
5
+ * Model: defaults to claude-3-5-haiku-20241022 (fast, affordable).
6
+ * Override via GITX_AI_MODEL env var.
7
+ *
8
+ * All methods send a structured system prompt and parse the JSON response.
9
+ * If parsing fails we fall back gracefully rather than crashing.
10
+ */
11
+ import type { AiAnalyzeTaskResponse, AiClient, AiGenerateDiffsResponse, AiGeneratePlanResponse, AiReviewPRResponse, AiSuggestFixesResponse, AiSummarizeChangesResponse } from "./types.js";
12
+ export declare class ClaudeAi implements AiClient {
13
+ private readonly apiKey;
14
+ private readonly model;
15
+ /**
16
+ * @param apiKey Anthropic API key. Falls back to ANTHROPIC_API_KEY env var.
17
+ * @param model Model override. Falls back to GITX_AI_MODEL env var then default.
18
+ */
19
+ constructor(apiKey?: string, model?: string);
20
+ /** Check whether an API key is available without instantiating the class. */
21
+ static isAvailable(key?: string): boolean;
22
+ analyzeTask(input: string): Promise<AiAnalyzeTaskResponse>;
23
+ generatePlan(context: unknown): Promise<AiGeneratePlanResponse>;
24
+ generateDiffs(step: unknown): Promise<AiGenerateDiffsResponse>;
25
+ summarizeChanges(diff: unknown): Promise<AiSummarizeChangesResponse>;
26
+ suggestFixes(comment: unknown): Promise<AiSuggestFixesResponse>;
27
+ reviewPR(context: unknown): Promise<AiReviewPRResponse>;
28
+ generatePrContent(commits: string[], diff: string, stat?: string): Promise<import("./types.js").AiPrContentResponse>;
29
+ resolveConflict(filePath: string, conflictContent: string): Promise<import("./types.js").AiConflictResolutionResponse>;
30
+ generateCommitMessage(diff: string): Promise<import("./types.js").AiCommitMessageResponse>;
31
+ reviewPRDetailed(context: Parameters<import("./types.js").AiClient["reviewPRDetailed"]>[0]): Promise<import("./types.js").AiDetailedReviewResponse>;
32
+ generateFix(context: Parameters<import("./types.js").AiClient["generateFix"]>[0]): Promise<import("./types.js").AiFixResponse>;
33
+ ask(question: string, context: import("./types.js").AiAskContext): Promise<import("./types.js").AiAskResponse>;
34
+ }
35
+ //# sourceMappingURL=claudeAi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claudeAi.d.ts","sourceRoot":"","sources":["../../src/ai/claudeAi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AA+FpB,qBAAa,QAAS,YAAW,QAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;OAGG;gBACS,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAY3C,6EAA6E;IAC7E,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO;IAInC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAqB1D,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA8C/D,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAuD9D,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAgCpE,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA+C/D,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoDvD,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,YAAY,EAAE,mBAAmB,CAAC;IAmCpH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,YAAY,EAAE,4BAA4B,CAAC;IA+BtH,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,YAAY,EAAE,uBAAuB,CAAC;IA+B1F,gBAAgB,CACpB,OAAO,EAAE,UAAU,CAAC,OAAO,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,GACxE,OAAO,CAAC,OAAO,YAAY,EAAE,wBAAwB,CAAC;IAWnD,WAAW,CACf,OAAO,EAAE,UAAU,CAAC,OAAO,YAAY,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GACnE,OAAO,CAAC,OAAO,YAAY,EAAE,aAAa,CAAC;IAWxC,GAAG,CACP,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,YAAY,EAAE,YAAY,GACzC,OAAO,CAAC,OAAO,YAAY,EAAE,aAAa,CAAC;CAK/C"}